smpl.stat

Simplified statistics.

Chi2(y, f[, sigmas])

Chi2 - Goodness of Fit

R2(y, f)

R2 - Coefficient of determination

mean(n)

Return mean of n with combined error of variance and unvertainties of n.

no_dist(N)

Return N with no uncertainties.

noisy(x[, mean, std])

Add gaussian noise to x.

normalize(ydata)

Return normalized ydata.

novar_mean(n)

Return mean of n with only the uncertainties of n and no variance.

poisson_dist(N)

Return N with added poissonian uncertainties.

unv(arr)

Return the nominal values of the numbers in NumPy array arr.

unv_lambda(f)

Returns a function which applies unv() on the result of f.

usd(arr)

Return the standard deviations of the numbers in NumPy array arr.

Functions

smpl.stat.Chi2(y, f, sigmas=None)[source]

Chi2 - Goodness of Fit

In general, if Chi-squared/Nd is of order 1.0, then the fit is reasonably good. Coversely, if Chi-squared/Nd >> 1.0, then the fit is a poor one.

References

https://www.phys.hawaii.edu/~varner/PHYS305-Spr12/DataFitting.html

smpl.stat.R2(y, f)[source]

R2 - Coefficient of determination

In the best case, the modeled values exactly match the observed values, which results in R2 = 1. A baseline model, which always predicts the mean of y, will have R2 = 0. Models that have worse predictions than this baseline will have a negative R2.

References

https://en.wikipedia.org/wiki/Coefficient_of_determination

smpl.stat.mean(n)[source]

Return mean of n with combined error of variance and unvertainties of n.

smpl.stat.no_dist(N)[source]

Return N with no uncertainties.

smpl.stat.noisy(x, mean=0, std=1)[source]

Add gaussian noise to x.

smpl.stat.normalize(ydata)[source]

Return normalized ydata.

smpl.stat.novar_mean(n)[source]

Return mean of n with only the uncertainties of n and no variance.

smpl.stat.poisson_dist(N)[source]

Return N with added poissonian uncertainties.

smpl.stat.unv(arr)

Return the nominal values of the numbers in NumPy array arr.

Elements that are not numbers with uncertainties (derived from a class from this module) are passed through untouched (because a numpy.array can contain numbers with uncertainties and pure floats simultaneously).

If arr is of type unumpy.matrix, the returned array is a numpy.matrix, because the resulting matrix does not contain numbers with uncertainties.

smpl.stat.unv_lambda(f)[source]

Returns a function which applies unv() on the result of f.

smpl.stat.usd(arr)

Return the standard deviations of the numbers in NumPy array arr.

Elements that are not numbers with uncertainties (derived from a class from this module) are passed through untouched (because a numpy.array can contain numbers with uncertainties and pure floats simultaneously).

If arr is of type unumpy.matrix, the returned array is a numpy.matrix, because the resulting matrix does not contain numbers with uncertainties.