it.uniroma2.sag.kelp.utils

## Class Math

• public class Math
extends Object
Implements static utility methods for mathematical operations and statistics
Author:
Simone Filice
• ### Constructor Summary

Constructors
Constructor and Description
Math()
• ### Method Summary

Methods
Modifier and Type Method and Description
static float getMean(float[] values)
Computes the arithmetic mean $$\bar{x}$$ of the input values $$x_1, \ldots x_n$$
static double getStandardDeviation(float[] values)
Estimates the unbiased standard deviation $$\sigma$$ of population using some samples $$x_1, \ldots x_n$$ whose estimated mean is $$\bar{x}$$
static float getVariance(float[] values)
Estimates the unbiased sample variance $$\sigma^2$$ of population using some samples $$x_1, \ldots x_n$$ whose estimated mean is $$\bar{x}$$
static float pow(float base, int exponent)
It evaluates the power of a number
static float softmax(float a, float b)
Approximates the max of two values with the following formula: $$softmax(a,b) = \frac{log(e^{Fa} + e^{Fb})}{F}$$
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### Math

public Math()
• ### Method Detail

• #### pow

public static float pow(float base,
int exponent)
It evaluates the power of a number
Parameters:
base - the base
exponent - the exponent
Returns:
$$base^{exponent}$$
• #### getMean

public static float getMean(float[] values)
Computes the arithmetic mean $$\bar{x}$$ of the input values $$x_1, \ldots x_n$$

$$\bar{x} = \frac{1}{n} \sum_{i=1}^{n}x_i$$

Parameters:
values - the input values on which computing the arithmetic mean
Returns:
the mean
• #### getVariance

public static float getVariance(float[] values)
Estimates the unbiased sample variance $$\sigma^2$$ of population using some samples $$x_1, \ldots x_n$$ whose estimated mean is $$\bar{x}$$

$$\sigma^2 = \frac{1}{n-1} \sum_{i=1}^{n}(x_i -\bar{x_i})^2$$

Parameters:
values - the samples of the population whose variance must be estimated
Returns:
the unbiased sample variance
• #### getStandardDeviation

public static double getStandardDeviation(float[] values)
Estimates the unbiased standard deviation $$\sigma$$ of population using some samples $$x_1, \ldots x_n$$ whose estimated mean is $$\bar{x}$$

$$\sigma = \sqrt{\frac{1}{n-1} \sum_{i=1}^{n}(x_i -\bar{x_i})^2}$$

Parameters:
values - the samples of the population whose standard deviation must be estimated
Returns:
the unbiased sample standard deviation
• #### softmax

public static float softmax(float a,
float b)
Approximates the max of two values with the following formula: $$softmax(a,b) = \frac{log(e^{Fa} + e^{Fb})}{F}$$

where F=100

This approximation is necessary when the max function is needed in a kernel to preserve its semi-positiveness (because the max does break this property)

Parameters:
a - the first value
b - the second value
Returns:
the approximation of max(a,b)