6.10.94-stable
In this page
Gaussian
The Gaussian type is a specialized container, which:
- accumulates data points, maintains their sum, sum squared, min, max
- computes basic statistics on the points collected: average, standard deviation
- normalizes (and inverse), standardizes (and inverse)
- computes probability, confidence, with collected data considered part of a normal distribution.
use util;
fn main() {
var g = Gaussian {}; // default object construction
g.add(12.4);
g.add(23.1);
g.add(15.6);
g.add(19.6);
g.add(17.6);
g.add(18.6);
println("[${g.min}, ${g.max}], avg=${g.avg()}");
println("prob(18.0) = ${g.probability(18.0)}");
println("conf(18.0) = ${g.confidence(18.0)}");
}
Displays:
[12.4, 23.1], avg=17.8166666667
prob(18.0) = 0.1096586343
conf(18.0) = 0.959757557
Reference
type Gaussian {
sum: float?;
sum_sq: float?;
count: int?;
min : float?;
max: float?;
/// Adds a new value to the profile. Returns true if the value has successfully been added, false otherwise.
native fn add(value: float?);
/// Returns the standard deviation of the accepted values in the profile.
native fn std(): float?;
/// Returns the average of the accepted values in the profile.
native fn avg(): float?;
/// Does (value-min)/(max-min)
native fn normalize(value: float): float?;
/// Does value*(max-min)+min
native fn inverse_normalize(value: float): float;
/// Does (value-avg)/(std)
native fn standardize(value: float): float;
/// Does (value*std)+avg
native fn inverse_standardize(value: float): float;
/// Returns the probability of obtaining `value` with respect to the normal law described by all the values from the profile.
native fn probability(value: float): float;
/// Return the confidence given a value
native fn confidence(value: float): float;
}