Documentation
¶
Overview ¶
Package stats is probability distributions, descriptive statistics and statistical tests in pure Go (no cgo), with the results of scipy.stats and NumPy's statistics, measured against mpmath to be at least as accurate as SciPy in 1473 of 1479 regions (the exceptions, all beta sf and ppf within 4.5 ulp, are listed in docs/accuracy.md).
Distributions ¶
Every distribution is a struct of its parameters with SciPy's names and meaning, plus Loc and Scale (continuous) or Loc (discrete):
stats.Normal{Loc: 0, Scale: 1}.PDF(1.5) // scipy.stats.norm.pdf(1.5)
stats.Beta{A: 2, B: 5, Scale: 1}.PPF(0.975) // scipy.stats.beta.ppf(0.975, 2, 5)
stats.Binomial{N: 10, P: 0.3}.PMF(4) // scipy.stats.binom.pmf(4, 10, 0.3)
with the methods of a frozen SciPy distribution (Continuous, Discrete): PDF/PMF, LogPDF, CDF, LogCDF, SF, LogSF, PPF, ISF, Mean, Var, Std, Skew, Kurtosis, Median, Entropy, Moment, Interval, Support, Rvs and Validate. The zero value has Scale 0 and is invalid: methods then return NaN as SciPy does, and the NewXxx constructors return an error. Fits are FitXxx functions (scipy's xxx.fit, with FitOptions.Fixed for floc, fscale, fa ...). Map applies a method to a go-ndarray array in parallel.
Continuous: Normal, Beta, Gamma, ChiSquared, Chi, InverseGamma, StudentT, F, NoncentralChiSquared, Exponential, Uniform, LogNormal, Cauchy, Laplace, Logistic, Weibull, Pareto, Reciprocal (LogUniform), Gumbel, Triangular, HalfNormal, Rayleigh, Lomax, VonMises. Discrete: Bernoulli, Binomial, Poisson, Geometric, NegativeBinomial, Hypergeometric, DiscreteUniform, Zipf. Multivariate: MultivariateNormal, Dirichlet, Multinomial.
Draws ¶
Rvs takes a go-ndarray *random.Generator, which reproduces NumPy's numpy.random.Generator bit for bit for the same seed, and makes the generator calls SciPy's rvs makes, so that
stats.Normal{Loc: 10, Scale: 2}.Rvs(random.DefaultRNG(42), 1000)
is scipy.stats.norm.rvs(10, 2, size=1000, random_state=np.random.default_rng(42)) to the bit. docs/rvs-table.md lists, per distribution, how many draws are bit-identical to SciPy's (x86-64 build) and why the others differ.
Descriptive statistics and tests ¶
The functions take Data: a []float64 or a go-ndarray *ndarray.Array. Options are structs whose zero value (or nil) is SciPy's default; results are structs (Statistic, PValue, DF, confidence intervals where SciPy gives them). Quantiles and histograms are NumPy's to the bit, for all thirteen quantile methods.
Accuracy ¶
Every distribution function is measured in ULPs against mpmath over regions covering the bulk and both tails, next to SciPy's value at the same arguments; per-region budgets are enforced by go test on every CI architecture. See docs/accuracy.md.
Example (Array) ¶
scipy.stats.beta(2.5, 7).ppf([0.05, 0.5, 0.95]) through an array
package main
import (
"fmt"
"github.com/go-ndarray/ndarray"
"github.com/go-statistics/stats"
)
func main() {
p, _ := ndarray.FromData([]float64{0.05, 0.5, 0.95}, 3)
q := stats.Map(p, stats.Beta{A: 2.5, B: 7, Scale: 1}.PPF)
fmt.Println(q)
}
Output: Array(shape=[3], data=[0.07152999268253016 0.24603732885541796 0.51374106221438])
Example (Describe) ¶
numpy.percentile(x, [25, 50, 75]) and scipy.stats.describe(x)
package main
import (
"fmt"
"github.com/go-statistics/stats"
)
func main() {
x := []float64{2, 4, 4, 4, 5, 5, 7, 9}
q, _ := stats.Percentiles(x, []float64{25, 50, 75}, nil)
d, _ := stats.Describe(x, nil)
fmt.Println(q, d.Mean, d.Variance)
}
Output: [4 4.5 5.5] 5 4.571428571428571
Example (Fit) ¶
scipy.stats.gamma.fit(x, floc=0)
package main
import (
"fmt"
"github.com/go-ndarray/ndarray/random"
"github.com/go-statistics/stats"
)
func main() {
x, _ := stats.Gamma{A: 3, Scale: 2}.Rvs(random.DefaultRNG(1), 500)
g, _ := stats.FitGamma(x, &stats.FitOptions{Fixed: map[string]float64{"Loc": 0}})
fmt.Printf("a=%.4f scale=%.4f\n", g.A, g.Scale)
}
Output: a=3.3544 scale=1.7401
Example (GaussianKDE) ¶
scipy.stats.gaussian_kde(data)(points)
package main
import (
"fmt"
"github.com/go-statistics/stats"
)
func main() {
data := []float64{-1.2, -0.4, 0.1, 0.3, 0.9, 1.7}
k, _ := stats.NewGaussianKDE(data, nil)
d, _ := k.EvaluateSlice([]float64{0, 1})
fmt.Printf("%.6f %.6f\n", d[0], d[1])
}
Output: 0.329053 0.264227
Example (Normal) ¶
scipy.stats.norm.pdf(1.5), norm.logcdf(-40), norm.ppf(0.975)
package main
import (
"fmt"
"github.com/go-statistics/stats"
)
func main() {
n := stats.Normal{Loc: 0, Scale: 1}
fmt.Printf("%.17g\n%.17g\n%.17g\n", n.PDF(1.5), n.LogCDF(-40), n.PPF(0.975))
}
Output: 0.12951759566589172 -804.6084420137538 1.9599639845400538
Example (Rvs) ¶
scipy.stats.norm.rvs(loc=10, scale=2, size=3, random_state=np.random.default_rng(42))
package main
import (
"fmt"
"github.com/go-ndarray/ndarray/random"
"github.com/go-statistics/stats"
)
func main() {
x, _ := stats.Normal{Loc: 10, Scale: 2}.Rvs(random.DefaultRNG(42), 3)
fmt.Println(x)
}
Output: Array(shape=[3], data=[10.609434159508863 7.920031787519009 11.500902391612914])
Example (TTest) ¶
scipy.stats.ttest_ind(a, b, equal_var=False)
package main
import (
"fmt"
"github.com/go-statistics/stats"
)
func main() {
a := []float64{5.1, 4.9, 5.6, 5.8, 6.0, 5.3}
b := []float64{4.2, 4.8, 4.6, 5.0, 4.4}
r, _ := stats.TTestInd(a, b, &stats.TTestIndOptions{Welch: true})
ci, _ := r.ConfidenceInterval(0.95)
fmt.Printf("t=%.6f p=%.6f df=%.4f ci=[%.4f, %.4f]\n", r.Statistic, r.PValue, r.DF, ci.Low, ci.High)
}
Output: t=3.807667 p=0.004226 df=8.9328 ci=[0.3444, 1.3556]
Index ¶
- Constants
- Variables
- func Average[D Data](x D, o *MeanOptions) (avg, sumWeights float64, err error)
- func DifferentialEntropy[D Data](x D, o *DiffEntropyOptions) (float64, error)
- func Entropy[D Data](pk D, o *EntropyOptions) (float64, error)
- func FitMultivariateNormal(x *ndarray.Array, o *MultivariateNormalFitOptions) (mean []float64, cov *ndarray.Array, err error)
- func GMean[D Data](x D, o *PowerMeanOptions) (float64, error)
- func HMean[D Data](x D, o *PowerMeanOptions) (float64, error)
- func HistogramBinEdges[D Data](x D, o *HistogramOptions) ([]float64, error)
- func IQR[D Data](x D, o *IQROptions) (float64, error)
- func Kurtosis[D Data](x D, o *ShapeOptions) (float64, error)
- func Map(x *ndarray.Array, f func(float64) float64) *ndarray.Array
- func MapSlice(dst, src []float64, f func(float64) float64)
- func Mean[D Data](x D, o *MeanOptions) (float64, error)
- func Median[D Data](x D, o *MedianOptions) (float64, error)
- func MedianAbsDeviation[D Data](x D, o *MADOptions) (float64, error)
- func Moment[D Data](x D, order int, o *MomentOptions) (float64, error)
- func PMean[D Data](x D, p float64, o *PowerMeanOptions) (float64, error)
- func Percentile[D Data](x D, p float64, o *QuantileOptions) (float64, error)
- func Percentiles[D Data](x D, ps []float64, o *QuantileOptions) ([]float64, error)
- func Quantile[D Data](x D, q float64, o *QuantileOptions) (float64, error)
- func Quantiles[D Data](x D, qs []float64, o *QuantileOptions) ([]float64, error)
- func RankData[D Data](x D, method RankMethod) (D, error)
- func SEM[D Data](x D, o *DdofOptions) (float64, error)
- func Skew[D Data](x D, o *ShapeOptions) (float64, error)
- func Std[D Data](x D, o *MeanOptions) (float64, error)
- func TMax[D Data](x D, upper float64, o *BoundOptions) (float64, error)
- func TMean[D Data](x D, o *TrimmedOptions) (float64, error)
- func TMin[D Data](x D, lower float64, o *BoundOptions) (float64, error)
- func TSem[D Data](x D, o *TrimmedOptions) (float64, error)
- func TStd[D Data](x D, o *TrimmedOptions) (float64, error)
- func TVar[D Data](x D, o *TrimmedOptions) (float64, error)
- func Trim1[D Data](x D, proportion float64, tail Tail) (D, error)
- func TrimBoth[D Data](x D, proportion float64) (D, error)
- func TrimMean[D Data](x D, proportion float64) (float64, error)
- func Var[D Data](x D, o *MeanOptions) (float64, error)
- func Variation[D Data](x D, o *DdofOptions) (float64, error)
- func ZMap[D, C Data](scores D, compare C, o *DdofOptions) (D, error)
- func ZScore[D Data](x D, o *DdofOptions) (D, error)
- type ADDist
- type Alternative
- type AndersonResult
- type BandwidthRule
- type Bernoulli
- func (d Bernoulli) CDF(k float64) float64
- func (d Bernoulli) Entropy() float64
- func (d Bernoulli) ISF(q float64) float64
- func (d Bernoulli) Interval(confidence float64) (lo, hi float64)
- func (d Bernoulli) Kurtosis() float64
- func (d Bernoulli) LogCDF(k float64) float64
- func (d Bernoulli) LogPMF(k float64) float64
- func (d Bernoulli) LogSF(k float64) float64
- func (d Bernoulli) Mean() float64
- func (d Bernoulli) Median() float64
- func (d Bernoulli) Moment(n int) float64
- func (d Bernoulli) PMF(k float64) float64
- func (d Bernoulli) PPF(p float64) float64
- func (d Bernoulli) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Bernoulli) SF(k float64) float64
- func (d Bernoulli) Skew() float64
- func (d Bernoulli) Std() float64
- func (d Bernoulli) Support() (lo, hi float64)
- func (d Bernoulli) Validate() error
- func (d Bernoulli) Var() float64
- type Beta
- func (d Beta) CDF(x float64) float64
- func (d Beta) Entropy() float64
- func (d Beta) ISF(q float64) float64
- func (d Beta) Interval(confidence float64) (lo, hi float64)
- func (d Beta) Kurtosis() float64
- func (d Beta) LogCDF(x float64) float64
- func (d Beta) LogPDF(x float64) float64
- func (d Beta) LogSF(x float64) float64
- func (d Beta) Mean() float64
- func (d Beta) Median() float64
- func (d Beta) Moment(n int) float64
- func (d Beta) PDF(x float64) float64
- func (d Beta) PPF(p float64) float64
- func (d Beta) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Beta) SF(x float64) float64
- func (d Beta) Skew() float64
- func (d Beta) Std() float64
- func (d Beta) Support() (lo, hi float64)
- func (d Beta) Validate() error
- func (d Beta) Var() float64
- type BinRule
- type BinStatistic
- type BinnedOptions
- type BinnedResult
- type Binomial
- func (d Binomial) CDF(k float64) float64
- func (d Binomial) Entropy() float64
- func (d Binomial) ISF(q float64) float64
- func (d Binomial) Interval(confidence float64) (lo, hi float64)
- func (d Binomial) Kurtosis() float64
- func (d Binomial) LogCDF(k float64) float64
- func (d Binomial) LogPMF(k float64) float64
- func (d Binomial) LogSF(k float64) float64
- func (d Binomial) Mean() float64
- func (d Binomial) Median() float64
- func (d Binomial) Moment(n int) float64
- func (d Binomial) PMF(k float64) float64
- func (d Binomial) PPF(p float64) float64
- func (d Binomial) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Binomial) SF(k float64) float64
- func (d Binomial) Skew() float64
- func (d Binomial) Std() float64
- func (d Binomial) Support() (lo, hi float64)
- func (d Binomial) Validate() error
- func (d Binomial) Var() float64
- type BootstrapMethod
- type BootstrapOptions
- type BootstrapResult
- type BoundOptions
- type CDFEstimate
- type Cauchy
- func (d Cauchy) CDF(x float64) float64
- func (d Cauchy) Entropy() float64
- func (d Cauchy) ISF(q float64) float64
- func (d Cauchy) Interval(confidence float64) (lo, hi float64)
- func (d Cauchy) Kurtosis() float64
- func (d Cauchy) LogCDF(x float64) float64
- func (d Cauchy) LogPDF(x float64) float64
- func (d Cauchy) LogSF(x float64) float64
- func (d Cauchy) Mean() float64
- func (d Cauchy) Median() float64
- func (d Cauchy) Moment(n int) float64
- func (d Cauchy) PDF(x float64) float64
- func (d Cauchy) PPF(p float64) float64
- func (d Cauchy) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Cauchy) SF(x float64) float64
- func (d Cauchy) Skew() float64
- func (d Cauchy) Std() float64
- func (d Cauchy) Support() (lo, hi float64)
- func (d Cauchy) Validate() error
- func (d Cauchy) Var() float64
- type Chi
- func (d Chi) CDF(x float64) float64
- func (d Chi) Entropy() float64
- func (d Chi) ISF(q float64) float64
- func (d Chi) Interval(confidence float64) (lo, hi float64)
- func (d Chi) Kurtosis() float64
- func (d Chi) LogCDF(x float64) float64
- func (d Chi) LogPDF(x float64) float64
- func (d Chi) LogSF(x float64) float64
- func (d Chi) Mean() float64
- func (d Chi) Median() float64
- func (d Chi) Moment(n int) float64
- func (d Chi) PDF(x float64) float64
- func (d Chi) PPF(p float64) float64
- func (d Chi) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Chi) SF(x float64) float64
- func (d Chi) Skew() float64
- func (d Chi) Std() float64
- func (d Chi) Support() (lo, hi float64)
- func (d Chi) Validate() error
- func (d Chi) Var() float64
- type Chi2ContingencyOptions
- type Chi2ContingencyResult
- type ChiSquareOptions
- type ChiSquared
- func (d ChiSquared) CDF(x float64) float64
- func (d ChiSquared) Entropy() float64
- func (d ChiSquared) ISF(q float64) float64
- func (d ChiSquared) Interval(confidence float64) (lo, hi float64)
- func (d ChiSquared) Kurtosis() float64
- func (d ChiSquared) LogCDF(x float64) float64
- func (d ChiSquared) LogPDF(x float64) float64
- func (d ChiSquared) LogSF(x float64) float64
- func (d ChiSquared) Mean() float64
- func (d ChiSquared) Median() float64
- func (d ChiSquared) Moment(n int) float64
- func (d ChiSquared) PDF(x float64) float64
- func (d ChiSquared) PPF(p float64) float64
- func (d ChiSquared) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d ChiSquared) SF(x float64) float64
- func (d ChiSquared) Skew() float64
- func (d ChiSquared) Std() float64
- func (d ChiSquared) Support() (lo, hi float64)
- func (d ChiSquared) Validate() error
- func (d ChiSquared) Var() float64
- type ConfidenceInterval
- type Continuous
- type CorrelationOptions
- type Data
- type DdofOptions
- type DescribeResult
- type DiffEntropyMethod
- type DiffEntropyOptions
- type Dirichlet
- func (d *Dirichlet) Alpha() []float64
- func (d *Dirichlet) Cov() *ndarray.Array
- func (d *Dirichlet) Entropy() float64
- func (d *Dirichlet) LogPDF(x []float64) (float64, error)
- func (d *Dirichlet) LogPDFPoints(x *ndarray.Array) ([]float64, error)
- func (d *Dirichlet) Mean() []float64
- func (d *Dirichlet) PDF(x []float64) (float64, error)
- func (d *Dirichlet) PDFPoints(x *ndarray.Array) ([]float64, error)
- func (d *Dirichlet) Rvs(g *random.Generator, size int) (*ndarray.Array, error)
- func (d *Dirichlet) Var() []float64
- type Discrete
- type DiscreteUniform
- func (d DiscreteUniform) CDF(k float64) float64
- func (d DiscreteUniform) Entropy() float64
- func (d DiscreteUniform) ISF(q float64) float64
- func (d DiscreteUniform) Interval(confidence float64) (lo, hi float64)
- func (d DiscreteUniform) Kurtosis() float64
- func (d DiscreteUniform) LogCDF(k float64) float64
- func (d DiscreteUniform) LogPMF(k float64) float64
- func (d DiscreteUniform) LogSF(k float64) float64
- func (d DiscreteUniform) Mean() float64
- func (d DiscreteUniform) Median() float64
- func (d DiscreteUniform) Moment(n int) float64
- func (d DiscreteUniform) PMF(k float64) float64
- func (d DiscreteUniform) PPF(p float64) float64
- func (d DiscreteUniform) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d DiscreteUniform) SF(k float64) float64
- func (d DiscreteUniform) Skew() float64
- func (d DiscreteUniform) Std() float64
- func (d DiscreteUniform) Support() (lo, hi float64)
- func (d DiscreteUniform) Validate() error
- func (d DiscreteUniform) Var() float64
- type EntropyOptions
- type Exponential
- func (d Exponential) CDF(x float64) float64
- func (d Exponential) Entropy() float64
- func (d Exponential) ISF(q float64) float64
- func (d Exponential) Interval(confidence float64) (lo, hi float64)
- func (d Exponential) Kurtosis() float64
- func (d Exponential) LogCDF(x float64) float64
- func (d Exponential) LogPDF(x float64) float64
- func (d Exponential) LogSF(x float64) float64
- func (d Exponential) Mean() float64
- func (d Exponential) Median() float64
- func (d Exponential) Moment(n int) float64
- func (d Exponential) PDF(x float64) float64
- func (d Exponential) PPF(p float64) float64
- func (d Exponential) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Exponential) SF(x float64) float64
- func (d Exponential) Skew() float64
- func (d Exponential) Std() float64
- func (d Exponential) Support() (lo, hi float64)
- func (d Exponential) Validate() error
- func (d Exponential) Var() float64
- type F
- func (d F) CDF(x float64) float64
- func (d F) Entropy() float64
- func (d F) ISF(q float64) float64
- func (d F) Interval(confidence float64) (lo, hi float64)
- func (d F) Kurtosis() float64
- func (d F) LogCDF(x float64) float64
- func (d F) LogPDF(x float64) float64
- func (d F) LogSF(x float64) float64
- func (d F) Mean() float64
- func (d F) Median() float64
- func (d F) Moment(n int) float64
- func (d F) PDF(x float64) float64
- func (d F) PPF(p float64) float64
- func (d F) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d F) SF(x float64) float64
- func (d F) Skew() float64
- func (d F) Std() float64
- func (d F) Support() (lo, hi float64)
- func (d F) Validate() error
- func (d F) Var() float64
- type FOnewayOptions
- type FisherExactOptions
- type FitOptions
- type FreqOptions
- type FreqResult
- type Gamma
- func (d Gamma) CDF(x float64) float64
- func (d Gamma) Entropy() float64
- func (d Gamma) ISF(q float64) float64
- func (d Gamma) Interval(confidence float64) (lo, hi float64)
- func (d Gamma) Kurtosis() float64
- func (d Gamma) LogCDF(x float64) float64
- func (d Gamma) LogPDF(x float64) float64
- func (d Gamma) LogSF(x float64) float64
- func (d Gamma) Mean() float64
- func (d Gamma) Median() float64
- func (d Gamma) Moment(n int) float64
- func (d Gamma) PDF(x float64) float64
- func (d Gamma) PPF(p float64) float64
- func (d Gamma) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Gamma) SF(x float64) float64
- func (d Gamma) Skew() float64
- func (d Gamma) Std() float64
- func (d Gamma) Support() (lo, hi float64)
- func (d Gamma) Validate() error
- func (d Gamma) Var() float64
- type GaussianKDE
- func (k *GaussianKDE) ChoCov() *ndarray.Array
- func (k *GaussianKDE) Covariance() *ndarray.Array
- func (k *GaussianKDE) D() int
- func (k *GaussianKDE) Dataset() *ndarray.Array
- func (k *GaussianKDE) Evaluate(points *ndarray.Array) ([]float64, error)
- func (k *GaussianKDE) EvaluateSlice(x []float64) ([]float64, error)
- func (k *GaussianKDE) Factor() float64
- func (k *GaussianKDE) IntegrateBox(low, high []float64, o *MultivariateNormalCDFOptions) (float64, error)
- func (k *GaussianKDE) IntegrateBox1D(low, high float64) (float64, error)
- func (k *GaussianKDE) IntegrateGaussian(mean []float64, cov *ndarray.Array) (float64, error)
- func (k *GaussianKDE) IntegrateKDE(other *GaussianKDE) (float64, error)
- func (k *GaussianKDE) InvCov() *ndarray.Array
- func (k *GaussianKDE) LogDet() float64
- func (k *GaussianKDE) LogPDF(points *ndarray.Array) ([]float64, error)
- func (k *GaussianKDE) LogPDFSlice(x []float64) ([]float64, error)
- func (k *GaussianKDE) Marginal(dims ...int) (*GaussianKDE, error)
- func (k *GaussianKDE) N() int
- func (k *GaussianKDE) Neff() float64
- func (k *GaussianKDE) Resample(g *random.Generator, size int) (*ndarray.Array, error)
- func (k *GaussianKDE) ScottsFactor() float64
- func (k *GaussianKDE) SetBandwidth(b KDEBandwidth) error
- func (k *GaussianKDE) SilvermanFactor() float64
- func (k *GaussianKDE) Weights() []float64
- type GaussianKDEOptions
- type Geometric
- func (d Geometric) CDF(k float64) float64
- func (d Geometric) Entropy() float64
- func (d Geometric) ISF(q float64) float64
- func (d Geometric) Interval(confidence float64) (lo, hi float64)
- func (d Geometric) Kurtosis() float64
- func (d Geometric) LogCDF(k float64) float64
- func (d Geometric) LogPMF(k float64) float64
- func (d Geometric) LogSF(k float64) float64
- func (d Geometric) Mean() float64
- func (d Geometric) Median() float64
- func (d Geometric) Moment(n int) float64
- func (d Geometric) PMF(k float64) float64
- func (d Geometric) PPF(p float64) float64
- func (d Geometric) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Geometric) SF(k float64) float64
- func (d Geometric) Skew() float64
- func (d Geometric) Std() float64
- func (d Geometric) Support() (lo, hi float64)
- func (d Geometric) Validate() error
- func (d Geometric) Var() float64
- type Gumbel
- func (d Gumbel) CDF(x float64) float64
- func (d Gumbel) Entropy() float64
- func (d Gumbel) ISF(q float64) float64
- func (d Gumbel) Interval(confidence float64) (lo, hi float64)
- func (d Gumbel) Kurtosis() float64
- func (d Gumbel) LogCDF(x float64) float64
- func (d Gumbel) LogPDF(x float64) float64
- func (d Gumbel) LogSF(x float64) float64
- func (d Gumbel) Mean() float64
- func (d Gumbel) Median() float64
- func (d Gumbel) Moment(n int) float64
- func (d Gumbel) PDF(x float64) float64
- func (d Gumbel) PPF(p float64) float64
- func (d Gumbel) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Gumbel) SF(x float64) float64
- func (d Gumbel) Skew() float64
- func (d Gumbel) Std() float64
- func (d Gumbel) Support() (lo, hi float64)
- func (d Gumbel) Validate() error
- func (d Gumbel) Var() float64
- type HalfNormal
- func (d HalfNormal) CDF(x float64) float64
- func (d HalfNormal) Entropy() float64
- func (d HalfNormal) ISF(q float64) float64
- func (d HalfNormal) Interval(confidence float64) (lo, hi float64)
- func (d HalfNormal) Kurtosis() float64
- func (d HalfNormal) LogCDF(x float64) float64
- func (d HalfNormal) LogPDF(x float64) float64
- func (d HalfNormal) LogSF(x float64) float64
- func (d HalfNormal) Mean() float64
- func (d HalfNormal) Median() float64
- func (d HalfNormal) Moment(n int) float64
- func (d HalfNormal) PDF(x float64) float64
- func (d HalfNormal) PPF(p float64) float64
- func (d HalfNormal) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d HalfNormal) SF(x float64) float64
- func (d HalfNormal) Skew() float64
- func (d HalfNormal) Std() float64
- func (d HalfNormal) Support() (lo, hi float64)
- func (d HalfNormal) Validate() error
- func (d HalfNormal) Var() float64
- type HistogramOptions
- type HistogramResult
- type Hypergeometric
- func (d Hypergeometric) CDF(k float64) float64
- func (d Hypergeometric) Entropy() float64
- func (d Hypergeometric) ISF(q float64) float64
- func (d Hypergeometric) Interval(confidence float64) (lo, hi float64)
- func (d Hypergeometric) Kurtosis() float64
- func (d Hypergeometric) LogCDF(k float64) float64
- func (d Hypergeometric) LogPMF(k float64) float64
- func (d Hypergeometric) LogSF(k float64) float64
- func (d Hypergeometric) Mean() float64
- func (d Hypergeometric) Median() float64
- func (d Hypergeometric) Moment(n int) float64
- func (d Hypergeometric) PMF(k float64) float64
- func (d Hypergeometric) PPF(p float64) float64
- func (d Hypergeometric) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Hypergeometric) SF(k float64) float64
- func (d Hypergeometric) Skew() float64
- func (d Hypergeometric) Std() float64
- func (d Hypergeometric) Support() (lo, hi float64)
- func (d Hypergeometric) Validate() error
- func (d Hypergeometric) Var() float64
- type IQROptions
- type InverseGamma
- func (d InverseGamma) CDF(x float64) float64
- func (d InverseGamma) Entropy() float64
- func (d InverseGamma) ISF(q float64) float64
- func (d InverseGamma) Interval(confidence float64) (lo, hi float64)
- func (d InverseGamma) Kurtosis() float64
- func (d InverseGamma) LogCDF(x float64) float64
- func (d InverseGamma) LogPDF(x float64) float64
- func (d InverseGamma) LogSF(x float64) float64
- func (d InverseGamma) Mean() float64
- func (d InverseGamma) Median() float64
- func (d InverseGamma) Moment(n int) float64
- func (d InverseGamma) PDF(x float64) float64
- func (d InverseGamma) PPF(p float64) float64
- func (d InverseGamma) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d InverseGamma) SF(x float64) float64
- func (d InverseGamma) Skew() float64
- func (d InverseGamma) Std() float64
- func (d InverseGamma) Support() (lo, hi float64)
- func (d InverseGamma) Validate() error
- func (d InverseGamma) Var() float64
- type KDEBandwidth
- type KSOptions
- type KSResult
- type KendallOptions
- type KendallVariant
- type Laplace
- func (d Laplace) CDF(x float64) float64
- func (d Laplace) Entropy() float64
- func (d Laplace) ISF(q float64) float64
- func (d Laplace) Interval(confidence float64) (lo, hi float64)
- func (d Laplace) Kurtosis() float64
- func (d Laplace) LogCDF(x float64) float64
- func (d Laplace) LogPDF(x float64) float64
- func (d Laplace) LogSF(x float64) float64
- func (d Laplace) Mean() float64
- func (d Laplace) Median() float64
- func (d Laplace) Moment(n int) float64
- func (d Laplace) PDF(x float64) float64
- func (d Laplace) PPF(p float64) float64
- func (d Laplace) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Laplace) SF(x float64) float64
- func (d Laplace) Skew() float64
- func (d Laplace) Std() float64
- func (d Laplace) Support() (lo, hi float64)
- func (d Laplace) Validate() error
- func (d Laplace) Var() float64
- type LeveneCenter
- type LeveneOptions
- type Limits
- type LinregressResult
- type LogNormal
- func (d LogNormal) CDF(x float64) float64
- func (d LogNormal) Entropy() float64
- func (d LogNormal) ISF(q float64) float64
- func (d LogNormal) Interval(confidence float64) (lo, hi float64)
- func (d LogNormal) Kurtosis() float64
- func (d LogNormal) LogCDF(x float64) float64
- func (d LogNormal) LogPDF(x float64) float64
- func (d LogNormal) LogSF(x float64) float64
- func (d LogNormal) Mean() float64
- func (d LogNormal) Median() float64
- func (d LogNormal) Moment(n int) float64
- func (d LogNormal) PDF(x float64) float64
- func (d LogNormal) PPF(p float64) float64
- func (d LogNormal) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d LogNormal) SF(x float64) float64
- func (d LogNormal) Skew() float64
- func (d LogNormal) Std() float64
- func (d LogNormal) Support() (lo, hi float64)
- func (d LogNormal) Validate() error
- func (d LogNormal) Var() float64
- type LogUniform
- type Logistic
- func (d Logistic) CDF(x float64) float64
- func (d Logistic) Entropy() float64
- func (d Logistic) ISF(q float64) float64
- func (d Logistic) Interval(confidence float64) (lo, hi float64)
- func (d Logistic) Kurtosis() float64
- func (d Logistic) LogCDF(x float64) float64
- func (d Logistic) LogPDF(x float64) float64
- func (d Logistic) LogSF(x float64) float64
- func (d Logistic) Mean() float64
- func (d Logistic) Median() float64
- func (d Logistic) Moment(n int) float64
- func (d Logistic) PDF(x float64) float64
- func (d Logistic) PPF(p float64) float64
- func (d Logistic) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Logistic) SF(x float64) float64
- func (d Logistic) Skew() float64
- func (d Logistic) Std() float64
- func (d Logistic) Support() (lo, hi float64)
- func (d Logistic) Validate() error
- func (d Logistic) Var() float64
- type Lomax
- func (d Lomax) CDF(x float64) float64
- func (d Lomax) Entropy() float64
- func (d Lomax) ISF(q float64) float64
- func (d Lomax) Interval(confidence float64) (lo, hi float64)
- func (d Lomax) Kurtosis() float64
- func (d Lomax) LogCDF(x float64) float64
- func (d Lomax) LogPDF(x float64) float64
- func (d Lomax) LogSF(x float64) float64
- func (d Lomax) Mean() float64
- func (d Lomax) Median() float64
- func (d Lomax) Moment(n int) float64
- func (d Lomax) PDF(x float64) float64
- func (d Lomax) PPF(p float64) float64
- func (d Lomax) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Lomax) SF(x float64) float64
- func (d Lomax) Skew() float64
- func (d Lomax) Std() float64
- func (d Lomax) Support() (lo, hi float64)
- func (d Lomax) Validate() error
- func (d Lomax) Var() float64
- type MADOptions
- type MannWhitneyUOptions
- type MeanOptions
- type MedianOptions
- type Method
- type ModeResult
- type MomentOptions
- type Multinomial
- func (m *Multinomial) Cov() *ndarray.Array
- func (m *Multinomial) Entropy() float64
- func (m *Multinomial) LogPMF(x []float64) (float64, error)
- func (m *Multinomial) LogPMFPoints(x *ndarray.Array) ([]float64, error)
- func (m *Multinomial) Mean() []float64
- func (m *Multinomial) N() int
- func (m *Multinomial) P() []float64
- func (m *Multinomial) PMF(x []float64) (float64, error)
- func (m *Multinomial) PMFPoints(x *ndarray.Array) ([]float64, error)
- func (m *Multinomial) Rvs(g *random.Generator, size int) (*ndarray.Array, error)
- type MultivariateNormal
- func (m *MultivariateNormal) CDF(x []float64, o *MultivariateNormalCDFOptions) (float64, error)
- func (m *MultivariateNormal) CDFEstimate(x []float64, o *MultivariateNormalCDFOptions) (CDFEstimate, error)
- func (m *MultivariateNormal) CDFPoints(x *ndarray.Array, o *MultivariateNormalCDFOptions) ([]float64, error)
- func (m *MultivariateNormal) Cov() *ndarray.Array
- func (m *MultivariateNormal) Dim() int
- func (m *MultivariateNormal) Entropy() float64
- func (m *MultivariateNormal) LogCDF(x []float64, o *MultivariateNormalCDFOptions) (float64, error)
- func (m *MultivariateNormal) LogPDF(x []float64) (float64, error)
- func (m *MultivariateNormal) LogPDFPoints(x *ndarray.Array) ([]float64, error)
- func (m *MultivariateNormal) LogPDet() float64
- func (m *MultivariateNormal) Mean() []float64
- func (m *MultivariateNormal) PDF(x []float64) (float64, error)
- func (m *MultivariateNormal) PDFPoints(x *ndarray.Array) ([]float64, error)
- func (m *MultivariateNormal) Rank() int
- func (m *MultivariateNormal) Rvs(g *random.Generator, size int) (*ndarray.Array, error)
- type MultivariateNormalCDFOptions
- type MultivariateNormalFitOptions
- type MultivariateNormalOptions
- type NaNOptions
- type NegativeBinomial
- func (d NegativeBinomial) CDF(k float64) float64
- func (d NegativeBinomial) Entropy() float64
- func (d NegativeBinomial) ISF(q float64) float64
- func (d NegativeBinomial) Interval(confidence float64) (lo, hi float64)
- func (d NegativeBinomial) Kurtosis() float64
- func (d NegativeBinomial) LogCDF(k float64) float64
- func (d NegativeBinomial) LogPMF(k float64) float64
- func (d NegativeBinomial) LogSF(k float64) float64
- func (d NegativeBinomial) Mean() float64
- func (d NegativeBinomial) Median() float64
- func (d NegativeBinomial) Moment(n int) float64
- func (d NegativeBinomial) PMF(k float64) float64
- func (d NegativeBinomial) PPF(p float64) float64
- func (d NegativeBinomial) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d NegativeBinomial) SF(k float64) float64
- func (d NegativeBinomial) Skew() float64
- func (d NegativeBinomial) Std() float64
- func (d NegativeBinomial) Support() (lo, hi float64)
- func (d NegativeBinomial) Validate() error
- func (d NegativeBinomial) Var() float64
- type NoncentralChiSquared
- func (d NoncentralChiSquared) CDF(x float64) float64
- func (d NoncentralChiSquared) Entropy() float64
- func (d NoncentralChiSquared) ISF(q float64) float64
- func (d NoncentralChiSquared) Interval(confidence float64) (lo, hi float64)
- func (d NoncentralChiSquared) Kurtosis() float64
- func (d NoncentralChiSquared) LogCDF(x float64) float64
- func (d NoncentralChiSquared) LogPDF(x float64) float64
- func (d NoncentralChiSquared) LogSF(x float64) float64
- func (d NoncentralChiSquared) Mean() float64
- func (d NoncentralChiSquared) Median() float64
- func (d NoncentralChiSquared) Moment(n int) float64
- func (d NoncentralChiSquared) PDF(x float64) float64
- func (d NoncentralChiSquared) PPF(p float64) float64
- func (d NoncentralChiSquared) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d NoncentralChiSquared) SF(x float64) float64
- func (d NoncentralChiSquared) Skew() float64
- func (d NoncentralChiSquared) Std() float64
- func (d NoncentralChiSquared) Support() (lo, hi float64)
- func (d NoncentralChiSquared) Validate() error
- func (d NoncentralChiSquared) Var() float64
- type Normal
- func (d Normal) CDF(x float64) float64
- func (d Normal) Entropy() float64
- func (d Normal) ISF(q float64) float64
- func (d Normal) Interval(confidence float64) (lo, hi float64)
- func (d Normal) Kurtosis() float64
- func (d Normal) LogCDF(x float64) float64
- func (d Normal) LogPDF(x float64) float64
- func (d Normal) LogSF(x float64) float64
- func (d Normal) Mean() float64
- func (d Normal) Median() float64
- func (d Normal) Moment(n int) float64
- func (d Normal) PDF(x float64) float64
- func (d Normal) PPF(p float64) float64
- func (d Normal) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Normal) SF(x float64) float64
- func (d Normal) Skew() float64
- func (d Normal) Std() float64
- func (d Normal) Support() (lo, hi float64)
- func (d Normal) Validate() error
- func (d Normal) Var() float64
- type Pareto
- func (d Pareto) CDF(x float64) float64
- func (d Pareto) Entropy() float64
- func (d Pareto) ISF(q float64) float64
- func (d Pareto) Interval(confidence float64) (lo, hi float64)
- func (d Pareto) Kurtosis() float64
- func (d Pareto) LogCDF(x float64) float64
- func (d Pareto) LogPDF(x float64) float64
- func (d Pareto) LogSF(x float64) float64
- func (d Pareto) Mean() float64
- func (d Pareto) Median() float64
- func (d Pareto) Moment(n int) float64
- func (d Pareto) PDF(x float64) float64
- func (d Pareto) PPF(p float64) float64
- func (d Pareto) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Pareto) SF(x float64) float64
- func (d Pareto) Skew() float64
- func (d Pareto) Std() float64
- func (d Pareto) Support() (lo, hi float64)
- func (d Pareto) Validate() error
- func (d Pareto) Var() float64
- type PearsonResult
- type Poisson
- func (d Poisson) CDF(k float64) float64
- func (d Poisson) Entropy() float64
- func (d Poisson) ISF(q float64) float64
- func (d Poisson) Interval(confidence float64) (lo, hi float64)
- func (d Poisson) Kurtosis() float64
- func (d Poisson) LogCDF(k float64) float64
- func (d Poisson) LogPMF(k float64) float64
- func (d Poisson) LogSF(k float64) float64
- func (d Poisson) Mean() float64
- func (d Poisson) Median() float64
- func (d Poisson) Moment(n int) float64
- func (d Poisson) PMF(k float64) float64
- func (d Poisson) PPF(p float64) float64
- func (d Poisson) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Poisson) SF(k float64) float64
- func (d Poisson) Skew() float64
- func (d Poisson) Std() float64
- func (d Poisson) Support() (lo, hi float64)
- func (d Poisson) Validate() error
- func (d Poisson) Var() float64
- type PowerMeanOptions
- type QuantileMethod
- type QuantileOptions
- type RankMethod
- type RankTestResult
- type Rayleigh
- func (d Rayleigh) CDF(x float64) float64
- func (d Rayleigh) Entropy() float64
- func (d Rayleigh) ISF(q float64) float64
- func (d Rayleigh) Interval(confidence float64) (lo, hi float64)
- func (d Rayleigh) Kurtosis() float64
- func (d Rayleigh) LogCDF(x float64) float64
- func (d Rayleigh) LogPDF(x float64) float64
- func (d Rayleigh) LogSF(x float64) float64
- func (d Rayleigh) Mean() float64
- func (d Rayleigh) Median() float64
- func (d Rayleigh) Moment(n int) float64
- func (d Rayleigh) PDF(x float64) float64
- func (d Rayleigh) PPF(p float64) float64
- func (d Rayleigh) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Rayleigh) SF(x float64) float64
- func (d Rayleigh) Skew() float64
- func (d Rayleigh) Std() float64
- func (d Rayleigh) Support() (lo, hi float64)
- func (d Rayleigh) Validate() error
- func (d Rayleigh) Var() float64
- type Reciprocal
- func (d Reciprocal) CDF(x float64) float64
- func (d Reciprocal) Entropy() float64
- func (d Reciprocal) ISF(q float64) float64
- func (d Reciprocal) Interval(confidence float64) (lo, hi float64)
- func (d Reciprocal) Kurtosis() float64
- func (d Reciprocal) LogCDF(x float64) float64
- func (d Reciprocal) LogPDF(x float64) float64
- func (d Reciprocal) LogSF(x float64) float64
- func (d Reciprocal) Mean() float64
- func (d Reciprocal) Median() float64
- func (d Reciprocal) Moment(n int) float64
- func (d Reciprocal) PDF(x float64) float64
- func (d Reciprocal) PPF(p float64) float64
- func (d Reciprocal) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Reciprocal) SF(x float64) float64
- func (d Reciprocal) Skew() float64
- func (d Reciprocal) Std() float64
- func (d Reciprocal) Support() (lo, hi float64)
- func (d Reciprocal) Validate() error
- func (d Reciprocal) Var() float64
- type ShapeOptions
- type SkewTestOptions
- type StudentT
- func (d StudentT) CDF(x float64) float64
- func (d StudentT) Entropy() float64
- func (d StudentT) ISF(q float64) float64
- func (d StudentT) Interval(confidence float64) (lo, hi float64)
- func (d StudentT) Kurtosis() float64
- func (d StudentT) LogCDF(x float64) float64
- func (d StudentT) LogPDF(x float64) float64
- func (d StudentT) LogSF(x float64) float64
- func (d StudentT) Mean() float64
- func (d StudentT) Median() float64
- func (d StudentT) Moment(n int) float64
- func (d StudentT) PDF(x float64) float64
- func (d StudentT) PPF(p float64) float64
- func (d StudentT) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d StudentT) SF(x float64) float64
- func (d StudentT) Skew() float64
- func (d StudentT) Std() float64
- func (d StudentT) Support() (lo, hi float64)
- func (d StudentT) Validate() error
- func (d StudentT) Var() float64
- type TTestIndOptions
- type TTestOptions
- type TTestResult
- type Tail
- type TestResult
- func Bartlett[D Data](samples ...D) (TestResult, error)
- func ChiSquare[D Data](observed D, o *ChiSquareOptions) (TestResult, error)
- func FOneway[D Data](o *FOnewayOptions, samples ...D) (TestResult, error)
- func FisherExact(table [2][2]int64, o *FisherExactOptions) (TestResult, error)
- func JarqueBera[D Data](x D) (TestResult, error)
- func Kendalltau[D Data](x, y D, o *KendallOptions) (TestResult, error)
- func KruskalWallis[D Data](samples ...D) (TestResult, error)
- func KurtosisTest[D Data](x D, o *SkewTestOptions) (TestResult, error)
- func Levene[D Data](o *LeveneOptions, samples ...D) (TestResult, error)
- func Normaltest[D Data](x D) (TestResult, error)
- func PowerDivergence[D Data](observed D, lambda float64, o *ChiSquareOptions) (TestResult, error)
- func ShapiroWilk[D Data](x D) (TestResult, error)
- func SkewTest[D Data](x D, o *SkewTestOptions) (TestResult, error)
- func Spearmanr[D Data](x, y D, o *CorrelationOptions) (TestResult, error)
- type Triangular
- func (d Triangular) CDF(x float64) float64
- func (d Triangular) Entropy() float64
- func (d Triangular) ISF(q float64) float64
- func (d Triangular) Interval(confidence float64) (lo, hi float64)
- func (d Triangular) Kurtosis() float64
- func (d Triangular) LogCDF(x float64) float64
- func (d Triangular) LogPDF(x float64) float64
- func (d Triangular) LogSF(x float64) float64
- func (d Triangular) Mean() float64
- func (d Triangular) Median() float64
- func (d Triangular) Moment(n int) float64
- func (d Triangular) PDF(x float64) float64
- func (d Triangular) PPF(p float64) float64
- func (d Triangular) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Triangular) SF(x float64) float64
- func (d Triangular) Skew() float64
- func (d Triangular) Std() float64
- func (d Triangular) Support() (lo, hi float64)
- func (d Triangular) Validate() error
- func (d Triangular) Var() float64
- type TrimmedOptions
- type Uniform
- func (d Uniform) CDF(x float64) float64
- func (d Uniform) Entropy() float64
- func (d Uniform) ISF(q float64) float64
- func (d Uniform) Interval(confidence float64) (lo, hi float64)
- func (d Uniform) Kurtosis() float64
- func (d Uniform) LogCDF(x float64) float64
- func (d Uniform) LogPDF(x float64) float64
- func (d Uniform) LogSF(x float64) float64
- func (d Uniform) Mean() float64
- func (d Uniform) Median() float64
- func (d Uniform) Moment(n int) float64
- func (d Uniform) PDF(x float64) float64
- func (d Uniform) PPF(p float64) float64
- func (d Uniform) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Uniform) SF(x float64) float64
- func (d Uniform) Skew() float64
- func (d Uniform) Std() float64
- func (d Uniform) Support() (lo, hi float64)
- func (d Uniform) Validate() error
- func (d Uniform) Var() float64
- type VonMises
- func (d VonMises) CDF(x float64) float64
- func (d VonMises) Entropy() float64
- func (d VonMises) ISF(q float64) float64
- func (d VonMises) Interval(confidence float64) (lo, hi float64)
- func (d VonMises) Kurtosis() float64
- func (d VonMises) LogCDF(x float64) float64
- func (d VonMises) LogPDF(x float64) float64
- func (d VonMises) LogSF(x float64) float64
- func (d VonMises) Mean() float64
- func (d VonMises) Median() float64
- func (d VonMises) Moment(n int) float64
- func (d VonMises) PDF(x float64) float64
- func (d VonMises) PPF(p float64) float64
- func (d VonMises) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d VonMises) SF(x float64) float64
- func (d VonMises) Skew() float64
- func (d VonMises) Std() float64
- func (d VonMises) Support() (lo, hi float64)
- func (d VonMises) Validate() error
- func (d VonMises) Var() float64
- type Weibull
- func (d Weibull) CDF(x float64) float64
- func (d Weibull) Entropy() float64
- func (d Weibull) ISF(q float64) float64
- func (d Weibull) Interval(confidence float64) (lo, hi float64)
- func (d Weibull) Kurtosis() float64
- func (d Weibull) LogCDF(x float64) float64
- func (d Weibull) LogPDF(x float64) float64
- func (d Weibull) LogSF(x float64) float64
- func (d Weibull) Mean() float64
- func (d Weibull) Median() float64
- func (d Weibull) Moment(n int) float64
- func (d Weibull) PDF(x float64) float64
- func (d Weibull) PPF(p float64) float64
- func (d Weibull) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Weibull) SF(x float64) float64
- func (d Weibull) Skew() float64
- func (d Weibull) Std() float64
- func (d Weibull) Support() (lo, hi float64)
- func (d Weibull) Validate() error
- func (d Weibull) Var() float64
- type WilcoxonOptions
- type ZeroMethod
- type Zipf
- func (d Zipf) CDF(k float64) float64
- func (d Zipf) Entropy() float64
- func (d Zipf) ISF(q float64) float64
- func (d Zipf) Interval(confidence float64) (lo, hi float64)
- func (d Zipf) Kurtosis() float64
- func (d Zipf) LogCDF(k float64) float64
- func (d Zipf) LogPMF(k float64) float64
- func (d Zipf) LogSF(k float64) float64
- func (d Zipf) Mean() float64
- func (d Zipf) Median() float64
- func (d Zipf) Moment(n int) float64
- func (d Zipf) PMF(k float64) float64
- func (d Zipf) PPF(p float64) float64
- func (d Zipf) Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
- func (d Zipf) SF(k float64) float64
- func (d Zipf) Skew() float64
- func (d Zipf) Std() float64
- func (d Zipf) Support() (lo, hi float64)
- func (d Zipf) Validate() error
- func (d Zipf) Var() float64
Examples ¶
Constants ¶
const ( LambdaPearson = 1.0 // "pearson": Pearson's chi-squared LambdaLogLikelihood = 0.0 // "log-likelihood": the G-test LambdaFreemanTukey = -0.5 // "freeman-tukey" LambdaModLogLikelihood = -1.0 // "mod-log-likelihood" LambdaNeyman = -2.0 // "neyman" LambdaCressieRead = 2.0 / 3.0 // "cressie-read" )
The Cressie-Read power λ of PowerDivergence: SciPy's named lambda_ values.
const ( // IQRNormal is 2 Φ⁻¹(3/4), scipy.stats.iqr's scale="normal". IQRNormal = 1.3489795003921634 // MADNormal is Φ⁻¹(3/4), scipy.stats.median_abs_deviation's // scale="normal". MADNormal = 0.6744897501960817 )
Scales of IQR and MedianAbsDeviation that make them consistent estimators of the standard deviation of a normal sample (SciPy's scale="normal").
Variables ¶
var ( // ErrParam reports a distribution parameter or an option outside its // domain (a non-positive scale, a probability outside [0, 1], ...). ErrParam = errors.New("stats: parameter out of domain") // ErrData reports data a computation cannot use: too few observations, // mismatched lengths, a negative count, a NaN where it has no meaning. ErrData = errors.New("stats: invalid data") // ErrFit reports a fit that did not converge to a finite optimum. ErrFit = errors.New("stats: fit did not converge") )
The errors returned by this package wrap one of these, so that a caller can test the kind with errors.Is.
Functions ¶
func Average ¶
func Average[D Data](x D, o *MeanOptions) (avg, sumWeights float64, err error)
Average returns the weighted mean and the sum of the weights (n without weights): numpy.average(x, weights=w, returned=True), to the bit.
func DifferentialEntropy ¶
func DifferentialEntropy[D Data](x D, o *DiffEntropyOptions) (float64, error)
DifferentialEntropy estimates the differential entropy of the continuous distribution the sample comes from, by the m-spacing estimators: scipy.stats.differential_entropy(x, window_length, base, method). It needs 2 <= 2m < n.
func Entropy ¶
func Entropy[D Data](pk D, o *EntropyOptions) (float64, error)
Entropy returns the Shannon entropy -Σ p log p of the distribution pk (normalised to sum 1), or the relative entropy Σ p log(p/q) when QK is given: scipy.stats.entropy(pk, qk, base). A NaN gives NaN.
func FitMultivariateNormal ¶
func FitMultivariateNormal(x *ndarray.Array, o *MultivariateNormalFitOptions) (mean []float64, cov *ndarray.Array, err error)
FitMultivariateNormal returns the maximum likelihood estimates of the mean and the covariance (with divisor n, ddof 0) from x, n points of dimension d as the rows of an n×d array: scipy.stats.multivariate_normal. fit(x, fix_mean, fix_cov). The mean is NumPy's column mean to the bit.
func GMean ¶
func GMean[D Data](x D, o *PowerMeanOptions) (float64, error)
GMean returns the geometric mean exp(mean(log x)): scipy.stats.gmean(x, weights=Weights). Negative data give NaN, a zero gives 0.
func HMean ¶
func HMean[D Data](x D, o *PowerMeanOptions) (float64, error)
HMean returns the harmonic mean 1/mean(1/x): scipy.stats.hmean(x, weights=Weights). Negative data give NaN.
func HistogramBinEdges ¶
func HistogramBinEdges[D Data](x D, o *HistogramOptions) ([]float64, error)
HistogramBinEdges returns the bin edges numpy.histogram_bin_edges(x, bins, range, weights) computes, to the bit.
func IQR ¶
func IQR[D Data](x D, o *IQROptions) (float64, error)
IQR returns the interquartile range (or the range between the two percentiles of Range): scipy.stats.iqr(x, rng=Range, scale=Scale, interpolation=Method).
func Kurtosis ¶
func Kurtosis[D Data](x D, o *ShapeOptions) (float64, error)
Kurtosis returns the sample (excess) kurtosis m4 / m2² - 3: scipy.stats.kurtosis(x, fisher=!Pearson, bias=!Unbiased). NaN when the data are constant.
func Map ¶
Map applies a scalar function (typically a distribution method value, d.CDF) to every element of x and returns a float64 array of x's shape: the vectorised call scipy.stats.<dist>.cdf(x, ...) makes. Large arrays are split into contiguous blocks evaluated on GOMAXPROCS goroutines; each element is computed by exactly one call of f, so the result does not depend on the number of goroutines. f must be safe for concurrent use (every method of this package's distributions is).
func MapSlice ¶
MapSlice sets dst[i] = f(src[i]) for every i (dst and src may be the same slice; dst must be at least as long as src), in parallel like Map.
func Mean ¶
func Mean[D Data](x D, o *MeanOptions) (float64, error)
Mean returns the arithmetic mean of the data: numpy.mean(x) (or numpy.nanmean, or numpy.average(x, weights=w)), to the bit.
func Median ¶
func Median[D Data](x D, o *MedianOptions) (float64, error)
Median returns the median of the data: numpy.median(x), to the bit (the middle order statistic, or the mean of the two middle ones).
func MedianAbsDeviation ¶
func MedianAbsDeviation[D Data](x D, o *MADOptions) (float64, error)
MedianAbsDeviation returns the median of |x - center| divided by Scale: scipy.stats.median_abs_deviation(x, center=Center, scale=Scale).
func Moment ¶
func Moment[D Data](x D, order int, o *MomentOptions) (float64, error)
Moment returns the sample moment of the given order about the mean (or Center): scipy.stats.moment(x, order, center=Center). Order 0 is 1, and order 1 about the mean is 0, as in SciPy.
func PMean ¶
func PMean[D Data](x D, p float64, o *PowerMeanOptions) (float64, error)
PMean returns the power mean mean(x^p)^(1/p): scipy.stats.pmean(x, p, weights=Weights); p = 0 is the geometric mean, and for |p| <= 2e-6 SciPy's first-order expansion about p = 0 is used. Negative data give NaN.
func Percentile ¶
func Percentile[D Data](x D, p float64, o *QuantileOptions) (float64, error)
Percentile returns the p-th percentile of the data, p in [0, 100]: numpy.percentile(x, p, method=...), to the bit (p/100 is then the quantile, as NumPy computes it).
func Percentiles ¶
func Percentiles[D Data](x D, ps []float64, o *QuantileOptions) ([]float64, error)
Percentiles returns the percentiles of the data at each p of ps: numpy.percentile(x, ps, method=...), to the bit.
func Quantile ¶
func Quantile[D Data](x D, q float64, o *QuantileOptions) (float64, error)
Quantile returns the q-th quantile of the data, q in [0, 1]: numpy.quantile(x, q, method=...), to the bit. The data are not modified (a copy is partially ordered by selection, not sorted).
func Quantiles ¶
func Quantiles[D Data](x D, qs []float64, o *QuantileOptions) ([]float64, error)
Quantiles returns the quantiles of the data at each q of qs: numpy.quantile(x, qs, method=...), to the bit.
func RankData ¶
func RankData[D Data](x D, method RankMethod) (D, error)
RankData assigns ranks 1..n to the data, ties handled by method: scipy.stats.rankdata(x, method) (axis=None, nan_policy="propagate": an array is ranked in row-major order as a whole, and when any value is NaN every rank is NaN). The result has the form of x (a []float64, or an array of x's shape).
func SEM ¶
func SEM[D Data](x D, o *DdofOptions) (float64, error)
SEM returns the standard error of the mean std(x, ddof)/sqrt(n): scipy.stats.sem(x, ddof=Ddof), ddof 1 by default.
func Skew ¶
func Skew[D Data](x D, o *ShapeOptions) (float64, error)
Skew returns the sample skewness m3 / m2^1.5: scipy.stats.skew(x, bias=!Unbiased). NaN when the data are constant.
func Std ¶
func Std[D Data](x D, o *MeanOptions) (float64, error)
Std returns the standard deviation: numpy.std(x, ddof=Ddof), to the bit.
func TMax ¶
func TMax[D Data](x D, upper float64, o *BoundOptions) (float64, error)
TMax returns the largest observation not above upper (math.Inf(1) for none): scipy.stats.tmax(x, upperlimit, inclusive=!Exclusive).
func TMean ¶
func TMean[D Data](x D, o *TrimmedOptions) (float64, error)
TMean returns the mean of the observations within the limits: scipy.stats.tmean(x, limits, inclusive).
func TMin ¶
func TMin[D Data](x D, lower float64, o *BoundOptions) (float64, error)
TMin returns the smallest observation not below lower (math.Inf(-1) for none): scipy.stats.tmin(x, lowerlimit, inclusive=!Exclusive).
func TSem ¶
func TSem[D Data](x D, o *TrimmedOptions) (float64, error)
TSem returns the standard error of the mean of the observations within the limits: scipy.stats.tsem.
func TStd ¶
func TStd[D Data](x D, o *TrimmedOptions) (float64, error)
TStd returns the square root of TVar: scipy.stats.tstd.
func TVar ¶
func TVar[D Data](x D, o *TrimmedOptions) (float64, error)
TVar returns the variance (ddof 1 by default) of the observations within the limits: scipy.stats.tvar(x, limits, inclusive, ddof=Ddof).
func Trim1 ¶
Trim1 returns the data without int(proportion n) observations at one end, in no particular order: scipy.stats.trim1(x, proportion, tail).
func TrimBoth ¶
TrimBoth returns the data without int(proportion n) observations at each end, in no particular order: scipy.stats.trimboth(x, proportion).
func TrimMean ¶
TrimMean returns the mean after cutting int(proportion n) observations from each end: scipy.stats.trim_mean(x, proportion).
func Var ¶
func Var[D Data](x D, o *MeanOptions) (float64, error)
Var returns the variance of the data: numpy.var(x, ddof=Ddof) (or numpy.nanvar), to the bit. With Weights it is the frequency-weighted variance sum(w (x - avg)²) / (sum(w) - Ddof).
func Variation ¶
func Variation[D Data](x D, o *DdofOptions) (float64, error)
Variation returns the coefficient of variation std(x, ddof)/mean(x): scipy.stats.variation(x, ddof=Ddof), ddof 0 by default.
func ZMap ¶
func ZMap[D, C Data](scores D, compare C, o *DdofOptions) (D, error)
ZMap returns (scores - mean(compare))/std(compare), in the form of scores: scipy.stats.zmap(scores, compare, ddof=Ddof), ddof 0 by default.
func ZScore ¶
func ZScore[D Data](x D, o *DdofOptions) (D, error)
ZScore returns (x - mean)/std for each observation, in the form of x: scipy.stats.zscore(x, ddof=Ddof), ddof 0 by default. All NaN when the data are constant.
Types ¶
type ADDist ¶
type ADDist int
ADDist is the distribution family of AndersonDarling (SciPy's dist=). The zero value is ADNorm, SciPy's default.
const ( ADNorm ADDist = iota // "norm": normal, mean and standard deviation estimated ADExpon // "expon": exponential, scale estimated (loc 0) ADLogistic // "logistic": logistic, by maximum likelihood ADGumbelL // "gumbel_l" ("gumbel", "extreme1"): left-skewed Gumbel, by maximum likelihood ADGumbelR // "gumbel_r": right-skewed Gumbel, by maximum likelihood )
type Alternative ¶
type Alternative int
Alternative is the alternative hypothesis of a test or the side of a confidence interval, SciPy's alternative= argument. The zero value is TwoSided, SciPy's default.
const ( // TwoSided is alternative="two-sided". TwoSided Alternative = iota // Less is alternative="less": the statistic (or the location of the // first sample) is less than under the null hypothesis. Less // Greater is alternative="greater". Greater )
func (Alternative) String ¶
func (a Alternative) String() string
String returns SciPy's name for the alternative.
type AndersonResult ¶
type AndersonResult struct {
// Statistic is the Anderson-Darling statistic A².
Statistic float64
// PValue is the p-value interpolated linearly in the table of
// critical values (SciPy's method="interpolate"), clamped to the
// table's significance levels at its ends.
PValue float64
// CriticalValues are the critical values for SignificanceLevels (in
// percent), as SciPy returns them (rounded to 3 decimals).
CriticalValues, SignificanceLevels []float64
// Loc and Scale are the fitted parameters of the distribution.
Loc, Scale float64
}
AndersonResult is the outcome of AndersonDarling (SciPy's AndersonResult and, for the p-value, the SignificanceResult of method="interpolate").
func AndersonDarling ¶
func AndersonDarling[D Data](x D, dist ADDist) (AndersonResult, error)
AndersonDarling is the Anderson-Darling test of the null hypothesis that the data come from the given family, its parameters estimated from the data: scipy.stats.anderson(x, dist) with the critical values and significance levels, and the p-value of method="interpolate".
type BandwidthRule ¶
type BandwidthRule int
BandwidthRule is a rule of thumb for the bandwidth factor of a GaussianKDE. The zero value is Scott's rule, SciPy's default.
const ( // BandwidthScott is Scott's rule, neff^(-1/(d+4)) (bw_method="scott"). BandwidthScott BandwidthRule = iota // BandwidthSilverman is Silverman's rule, (neff·(d+2)/4)^(-1/(d+4)) // (bw_method="silverman"). BandwidthSilverman )
type Bernoulli ¶
type Bernoulli struct {
P, Loc float64
}
Bernoulli is a single trial of success probability P: mass 1-P at 0 and P at 1: scipy.stats.bernoulli(p, loc). The zero value (P = 0) is the distribution concentrated at 0.
func NewBernoulli ¶
NewBernoulli returns Bernoulli{P: p, Loc: loc}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.bernoulli(p, loc).
func (Bernoulli) Entropy ¶
Entropy is the Shannon entropy in nats: scipy.stats.bernoulli.entropy(p, loc).
func (Bernoulli) Interval ¶
Interval is the interval with the given probability mass between PPF((1-c)/2) and PPF((1+c)/2): scipy.stats.bernoulli.interval(confidence, p, loc).
func (Bernoulli) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.bernoulli.stats(p, loc, moments="k").
func (Bernoulli) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.bernoulli.moment(n, p, loc).
func (Bernoulli) PMF ¶
PMF is the probability mass P(X = k), zero unless k - Loc is an integer in the support: scipy.stats.bernoulli.pmf(k, p, loc).
func (Bernoulli) PPF ¶
PPF is the smallest k with CDF(k) >= p: scipy.stats.bernoulli.ppf(p, p, loc).
func (Bernoulli) Rvs ¶
Rvs draws random variates of the given shape as an int64 array: scipy.stats.bernoulli.rvs(p, loc, size=size, random_state=g).
func (Bernoulli) Support ¶
Support is the smallest and largest value with positive mass: scipy.stats.bernoulli.support(p, loc).
type Beta ¶
type Beta struct {
A, B, Loc, Scale float64
}
Beta is the beta distribution on [0, 1] with shapes A and B: density x^(A-1) (1-x)^(B-1) / B(A, B) in standard form: scipy.stats.beta(a, b, loc, scale).
CDF and SF are special.BetaInc and special.BetaIncC, PPF and ISF their inverses; the density is betaDensity (double-double exponent, Stirling form for large shapes), 1-x being exact on [1/2, 1].
func FitBeta ¶
func FitBeta[D Data](x D, o *FitOptions) (Beta, error)
FitBeta returns the maximum-likelihood beta distribution for x: scipy.stats.beta.fit(x, fa=, fb=, floc=, fscale=). With Loc and Scale both fixed it solves the likelihood equations ψ(a) - ψ(a+b) = mean log y, ψ(b) - ψ(a+b) = mean log(1-y) as SciPy does (to full precision); otherwise it maximises the likelihood numerically from SciPy's starting point.
func NewBeta ¶
NewBeta returns Beta{A: a, B: b, Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.beta(a, b, loc, scale).
func (Beta) Entropy ¶
Entropy is the differential entropy in nats: scipy.stats.beta.entropy(a, b, loc, scale).
func (Beta) Interval ¶
Interval is the equal-tailed interval with the given probability mass: scipy.stats.beta.interval(confidence, a, b, loc, scale).
func (Beta) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.beta.stats(a, b, loc, scale, moments="k").
func (Beta) LogPDF ¶
LogPDF is the logarithm of the density at x: scipy.stats.beta.logpdf(x, a, b, loc, scale).
func (Beta) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.beta.moment(n, a, b, loc, scale).
func (Beta) PPF ¶
PPF is the quantile function, the inverse of CDF: scipy.stats.beta.ppf(p, a, b, loc, scale).
func (Beta) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.beta.rvs(a, b, loc, scale, size=size, random_state=g).
func (Beta) Support ¶
Support is the interval where the density is positive: scipy.stats.beta.support(a, b, loc, scale).
type BinRule ¶
type BinRule int
BinRule is an estimator of the number of histogram bins, NumPy's bins="auto", "fd", ... The zero value BinsCount means "use Bins".
const ( // BinsCount uses HistogramOptions.Bins (or Edges). BinsCount BinRule = iota // BinsAuto is bins="auto": the smaller of the Sturges and the // Freedman-Diaconis widths (the latter at least half the sqrt width). BinsAuto // BinsFD is bins="fd" (Freedman-Diaconis): width 2 IQR n^(-1/3). BinsFD // BinsDoane is bins="doane". BinsDoane // BinsScott is bins="scott". BinsScott // BinsStone is bins="stone" (minimises the leave-one-out risk). BinsStone // BinsRice is bins="rice". BinsRice // BinsSturges is bins="sturges". BinsSturges // BinsSqrt is bins="sqrt". BinsSqrt )
type BinStatistic ¶
type BinStatistic int
BinStatistic is the statistic BinnedStatistic computes in each bin.
const ( // BinMean is statistic="mean" (the zero value, SciPy's default). BinMean BinStatistic = iota // BinStd is statistic="std" (ddof 0). BinStd // BinMedian is statistic="median". BinMedian // BinCount is statistic="count". BinCount // BinSum is statistic="sum". BinSum // BinMin is statistic="min". BinMin // BinMax is statistic="max". BinMax )
type BinnedOptions ¶
type BinnedOptions struct {
// Statistic is the statistic of each bin (default BinMean).
Statistic BinStatistic
// Bins is the number of equal-width bins (0 means 10).
Bins int
// Edges, when not nil, are the bin edges (increasing); they take
// precedence over Bins.
Edges []float64
// Range, when not nil, is the range of the equal-width bins; by default
// the minimum and maximum of x.
Range *[2]float64
}
BinnedOptions are the options of BinnedStatistic.
type BinnedResult ¶
type BinnedResult struct {
// Statistic is the statistic of the values in each bin (NaN for an
// empty bin, except 0 for BinCount and BinSum).
Statistic []float64
// Edges are the len(Statistic)+1 bin edges.
Edges []float64
// BinNumber is the bin of each observation, 1-based: 0 below the first
// edge and len(Edges) above the last.
BinNumber []int
}
BinnedResult is scipy.stats.binned_statistic's result.
func BinnedStatistic ¶
func BinnedStatistic[D, V Data](x D, values V, o *BinnedOptions) (BinnedResult, error)
BinnedStatistic computes a statistic of values in bins of x: scipy.stats.binned_statistic(x, values, statistic, bins, range). The bins are half-open [a, b) except the last, which is closed (to the precision SciPy rounds the last edge to).
type Binomial ¶
Binomial is the number of successes in N independent trials of probability P: mass C(N,k) P^k (1-P)^(N-k) on k = 0..N: scipy.stats.binom(n, p, loc).
PMF and LogPMF use Loader's saddle-point form (see binomTerm), accurate to about an ulp for every N up to 2^53 and in the far tails, where SciPy's logpmf (log-gamma differences) loses digits to cancellation. CDF and SF are special.BetaIncC and special.BetaInc; LogCDF and LogSF switch to log1p of the complement near 1 and, below the normal range, to the tail summed from its first mass. PPF and ISF follow SciPy's definition (the smallest k with CDF(k) >= p, resp. SF(k) <= q) from a Cornish-Fisher starting point.
func NewBinomial ¶
NewBinomial returns Binomial{N: n, P: p, Loc: loc}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.binom(n, p, loc).
func (Binomial) Entropy ¶
Entropy is the Shannon entropy in nats: scipy.stats.binom.entropy(n, p, loc).
func (Binomial) Interval ¶
Interval is the interval with the given probability mass between PPF((1-c)/2) and PPF((1+c)/2): scipy.stats.binom.interval(confidence, n, p, loc).
func (Binomial) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.binom.stats(n, p, loc, moments="k").
func (Binomial) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.binom.moment(n, n, p, loc).
func (Binomial) PMF ¶
PMF is the probability mass P(X = k), zero unless k - Loc is an integer in the support: scipy.stats.binom.pmf(k, n, p, loc).
func (Binomial) Rvs ¶
Rvs draws random variates of the given shape as an int64 array: scipy.stats.binom.rvs(n, p, loc, size=size, random_state=g).
func (Binomial) Support ¶
Support is the smallest and largest value with positive mass: scipy.stats.binom.support(n, p, loc).
type BootstrapMethod ¶
type BootstrapMethod int
BootstrapMethod is the kind of bootstrap confidence interval. The zero value is BootstrapBCa, SciPy's default.
const ( // BootstrapBCa is the bias-corrected and accelerated interval // (method="BCa"). BootstrapBCa BootstrapMethod = iota // BootstrapPercentile is the percentile interval (method="percentile"). BootstrapPercentile // BootstrapBasic is the basic (reverse percentile) interval // (method="basic"). BootstrapBasic )
func (BootstrapMethod) String ¶
func (m BootstrapMethod) String() string
String returns SciPy's name for the method.
type BootstrapOptions ¶
type BootstrapOptions struct {
// NResamples is the number of resamples; 0 is 9999.
NResamples int
// ConfidenceLevel is the confidence level, in (0, 1); 0 is 0.95.
ConfidenceLevel float64
// Method is the kind of interval.
Method BootstrapMethod
// Alternative makes the interval one-sided: Less gives (-∞, high],
// Greater [low, ∞).
Alternative Alternative
// Paired resamples the samples together, with the same indices (they
// must have the same length).
Paired bool
// Batch is the number of resamples drawn per call to the generator
// (SciPy's batch); 0 draws them all at once. It changes the draws.
Batch int
}
BootstrapOptions configures Bootstrap. The zero value is SciPy's default: 9999 resamples, a 95% two-sided BCa interval, independent samples, one batch.
type BootstrapResult ¶
type BootstrapResult struct {
// ConfidenceInterval is the bootstrap confidence interval.
ConfidenceInterval ConfidenceInterval
// BootstrapDistribution holds the statistic of each resample.
BootstrapDistribution []float64
// StandardError is the sample standard deviation (ddof 1) of the
// bootstrap distribution.
StandardError float64
}
BootstrapResult is the result of Bootstrap.
func Bootstrap ¶
func Bootstrap[D Data](samples []D, statistic func(samples ...[]float64) float64, g *random.Generator, o *BootstrapOptions) (BootstrapResult, error)
Bootstrap computes a bootstrap confidence interval for statistic, a function of one value per sample, from the given samples: scipy.stats.bootstrap(data, statistic, n_resamples, batch, paired, confidence_level, alternative, method, rng=g).
The resamples are SciPy's for the same generator: for each batch and each sample, g.Integers(0, n, (batch, n)) indices (one index matrix for all samples when Paired). With statistic the NumPy-exact mean of this package (NumPy's pairwise sum along the last axis, as np.mean(axis=-1) computes it), the bootstrap distribution and the interval are SciPy's to the bit. A nil g is a generator seeded from the operating system.
statistic is called once per resample (and, for BCa, once per jackknife sample) with slices it must not retain or modify. It returns an error wrapping ErrData when a sample has fewer than two observations or paired samples differ in length, and ErrParam for invalid options. The interval is NaN where SciPy's is (a degenerate bootstrap distribution under BCa, or a NaN statistic).
type BoundOptions ¶
type BoundOptions struct {
// Exclusive drops the observations equal to the limit (SciPy's
// inclusive=False).
Exclusive bool
// OmitNaN ignores the NaNs; by default a NaN gives NaN.
OmitNaN bool
}
BoundOptions are the options of TMin and TMax.
type CDFEstimate ¶
type CDFEstimate struct {
// Value is the probability.
Value float64
// Error is the error estimate: three standard errors of the randomized
// lattice batches for d ≥ 3, 1e-15 (nominal, as SciPy reports) for
// d ≤ 2 where the computation is deterministic.
Error float64
// NPoints is the number of integration points used (0 for d ≤ 2).
NPoints int
}
CDFEstimate is a multivariate normal probability with its error estimate.
type Cauchy ¶
type Cauchy struct {
Loc, Scale float64
}
Cauchy is the Cauchy (Lorentz) distribution with median Loc and half-width Scale: density 1/(π(1+x²)) in standard form: scipy.stats.cauchy(loc, scale).
The tail probabilities are atan(1/|x|)/π beyond 1 and 1/2 - atan(|x|)/π within, with a double-double arctangent (atanD), so that CDF and SF keep full relative accuracy in both tails; PPF and ISF are -cot(πp) or tan(π(p - 1/2)) from a double-double sine and cosine of an argument never above π/4, accurate where SciPy's tan(π(p - 1/2)) loses the low bits of p.
func FitCauchy ¶
func FitCauchy[D Data](x D, o *FitOptions) (Cauchy, error)
FitCauchy returns the maximum-likelihood Cauchy distribution for x: scipy.stats.cauchy.fit(x, floc=, fscale=), maximised numerically from SciPy's starting point (the median and half the interquartile range), to a tighter optimum than SciPy's.
func NewCauchy ¶
NewCauchy returns Cauchy{Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.cauchy(loc, scale).
func (Cauchy) Entropy ¶
Entropy is the differential entropy in nats: scipy.stats.cauchy.entropy(loc, scale).
func (Cauchy) Interval ¶
Interval is the equal-tailed interval with the given probability mass: scipy.stats.cauchy.interval(confidence, loc, scale).
func (Cauchy) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.cauchy.stats(loc, scale, moments="k").
func (Cauchy) LogPDF ¶
LogPDF is the logarithm of the density at x: scipy.stats.cauchy.logpdf(x, loc, scale).
func (Cauchy) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.cauchy.moment(n, loc, scale).
func (Cauchy) PPF ¶
PPF is the quantile function, the inverse of CDF: scipy.stats.cauchy.ppf(p, loc, scale).
func (Cauchy) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.cauchy.rvs(loc, scale, size=size, random_state=g).
func (Cauchy) Support ¶
Support is the interval where the density is positive: scipy.stats.cauchy.support(loc, scale).
type Chi ¶
type Chi struct {
Df, Loc, Scale float64
}
Chi is the chi distribution (the length of a standard normal vector in Df dimensions): scipy.stats.chi(df, loc, scale). Its functions are the gamma distribution's with shape Df/2 at x²/2, the square carried in double-double where the density needs it.
func FitChi ¶
func FitChi[D Data](x D, o *FitOptions) (Chi, error)
FitChi returns the maximum-likelihood chi distribution for x: scipy.stats.chi.fit(x, fdf=, floc=, fscale=), numerically from SciPy's starting point.
func NewChi ¶
NewChi returns Chi{Df: df, Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.chi(df, loc, scale).
func (Chi) Entropy ¶
Entropy is the differential entropy in nats: scipy.stats.chi.entropy(df, loc, scale).
func (Chi) Interval ¶
Interval is the equal-tailed interval with the given probability mass: scipy.stats.chi.interval(confidence, df, loc, scale).
func (Chi) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.chi.stats(df, loc, scale, moments="k").
func (Chi) LogPDF ¶
LogPDF is the logarithm of the density at x: scipy.stats.chi.logpdf(x, df, loc, scale).
func (Chi) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.chi.moment(n, df, loc, scale).
func (Chi) PPF ¶
PPF is the quantile function, the inverse of CDF: scipy.stats.chi.ppf(p, df, loc, scale).
func (Chi) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.chi.rvs(df, loc, scale, size=size, random_state=g).
func (Chi) Support ¶
Support is the interval where the density is positive: scipy.stats.chi.support(df, loc, scale).
type Chi2ContingencyOptions ¶
type Chi2ContingencyOptions struct {
// NoCorrection disables Yates' continuity correction (SciPy's
// correction=False).
NoCorrection bool
// Lambda, when not nil, selects the Cressie-Read power divergence
// statistic instead of Pearson's (SciPy's lambda_).
Lambda *float64
}
Chi2ContingencyOptions are the options of Chi2Contingency. The zero value (or nil) is SciPy's default: Yates' correction for 1 degree of freedom and Pearson's statistic.
type Chi2ContingencyResult ¶
type Chi2ContingencyResult struct {
Statistic, PValue float64
// DOF is the number of degrees of freedom.
DOF int
// Expected are the expected frequencies under independence, an array
// of the table's shape.
Expected *ndarray.Array
}
Chi2ContingencyResult is the outcome of Chi2Contingency.
func Chi2Contingency ¶
func Chi2Contingency(observed *ndarray.Array, o *Chi2ContingencyOptions) (Chi2ContingencyResult, error)
Chi2Contingency is the chi-squared test of independence of the variables of an N-dimensional contingency table of observed counts: scipy.stats.chi2_contingency(observed, correction, lambda_).
type ChiSquareOptions ¶
type ChiSquareOptions struct {
// Expected are the expected frequencies (SciPy's f_exp), one per
// observed frequency; nil means every category equally likely. Their
// sum must agree with that of the observed frequencies to a relative
// tolerance of sqrt(eps), as SciPy requires.
Expected []float64
// DDOF is the adjustment to the degrees of freedom: the p-value uses
// k - 1 - DDOF (SciPy's ddof).
DDOF int
}
ChiSquareOptions are the options of ChiSquare and PowerDivergence. The zero value (or nil) is SciPy's default: uniform expected frequencies and no extra degrees of freedom removed.
type ChiSquared ¶
type ChiSquared struct {
Df, Loc, Scale float64
}
ChiSquared is the chi-squared distribution with Df degrees of freedom: scipy.stats.chi2(df, loc, scale). It is the gamma distribution with shape Df/2 and scale 2, computed through it (x/2 and Df/2 are exact).
func FitChiSquared ¶
func FitChiSquared[D Data](x D, o *FitOptions) (ChiSquared, error)
FitChiSquared returns the maximum-likelihood chi-squared distribution for x: scipy.stats.chi2.fit(x, fdf=, floc=, fscale=), numerically from SciPy's starting point.
func NewChiSquared ¶
func NewChiSquared(df float64, loc, scale float64) (ChiSquared, error)
NewChiSquared returns ChiSquared{Df: df, Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.chi2(df, loc, scale).
func (ChiSquared) CDF ¶
func (d ChiSquared) CDF(x float64) float64
CDF is P(X <= x): scipy.stats.chi2.cdf(x, df, loc, scale).
func (ChiSquared) Entropy ¶
func (d ChiSquared) Entropy() float64
Entropy is the differential entropy in nats: scipy.stats.chi2.entropy(df, loc, scale).
func (ChiSquared) ISF ¶
func (d ChiSquared) ISF(q float64) float64
ISF is the inverse of SF: scipy.stats.chi2.isf(q, df, loc, scale).
func (ChiSquared) Interval ¶
func (d ChiSquared) Interval(confidence float64) (lo, hi float64)
Interval is the equal-tailed interval with the given probability mass: scipy.stats.chi2.interval(confidence, df, loc, scale).
func (ChiSquared) Kurtosis ¶
func (d ChiSquared) Kurtosis() float64
Kurtosis is the excess kurtosis: scipy.stats.chi2.stats(df, loc, scale, moments="k").
func (ChiSquared) LogCDF ¶
func (d ChiSquared) LogCDF(x float64) float64
LogCDF is log P(X <= x): scipy.stats.chi2.logcdf(x, df, loc, scale).
func (ChiSquared) LogPDF ¶
func (d ChiSquared) LogPDF(x float64) float64
LogPDF is the logarithm of the density at x: scipy.stats.chi2.logpdf(x, df, loc, scale).
func (ChiSquared) LogSF ¶
func (d ChiSquared) LogSF(x float64) float64
LogSF is log P(X > x): scipy.stats.chi2.logsf(x, df, loc, scale).
func (ChiSquared) Mean ¶
func (d ChiSquared) Mean() float64
Mean is E[X]: scipy.stats.chi2.mean(df, loc, scale).
func (ChiSquared) Median ¶
func (d ChiSquared) Median() float64
Median is the median: scipy.stats.chi2.median(df, loc, scale).
func (ChiSquared) Moment ¶
func (d ChiSquared) Moment(n int) float64
Moment is the non-central moment E[X^n]: scipy.stats.chi2.moment(n, df, loc, scale).
func (ChiSquared) PDF ¶
func (d ChiSquared) PDF(x float64) float64
PDF is the probability density at x: scipy.stats.chi2.pdf(x, df, loc, scale).
func (ChiSquared) PPF ¶
func (d ChiSquared) PPF(p float64) float64
PPF is the quantile function, the inverse of CDF: scipy.stats.chi2.ppf(p, df, loc, scale).
func (ChiSquared) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.chi2.rvs(df, loc, scale, size=size, random_state=g).
func (ChiSquared) SF ¶
func (d ChiSquared) SF(x float64) float64
SF is the survival function P(X > x): scipy.stats.chi2.sf(x, df, loc, scale).
func (ChiSquared) Skew ¶
func (d ChiSquared) Skew() float64
Skew is the skewness: scipy.stats.chi2.stats(df, loc, scale, moments="s").
func (ChiSquared) Std ¶
func (d ChiSquared) Std() float64
Std is the standard deviation: scipy.stats.chi2.std(df, loc, scale).
func (ChiSquared) Support ¶
func (d ChiSquared) Support() (lo, hi float64)
Support is the interval where the density is positive: scipy.stats.chi2.support(df, loc, scale).
func (ChiSquared) Validate ¶
func (d ChiSquared) Validate() error
Validate returns an error wrapping ErrParam unless Scale is positive and finite, Loc finite and the shape parameters in their domain.
func (ChiSquared) Var ¶
func (d ChiSquared) Var() float64
Var is the variance: scipy.stats.chi2.var(df, loc, scale).
type ConfidenceInterval ¶
type ConfidenceInterval struct {
Low, High float64
}
ConfidenceInterval is a confidence interval [Low, High] (SciPy's ConfidenceInterval(low, high) named tuple). A one-sided interval has an infinite bound.
type Continuous ¶
type Continuous interface {
// PDF is the probability density at x (scipy pdf).
PDF(x float64) float64
// LogPDF is log PDF(x), accurate where PDF underflows (scipy logpdf).
LogPDF(x float64) float64
// CDF is P(X <= x) (scipy cdf).
CDF(x float64) float64
// LogCDF is log CDF(x), accurate where CDF underflows (scipy logcdf).
LogCDF(x float64) float64
// SF is the survival function P(X > x) = 1 - CDF(x), computed without
// the cancellation (scipy sf).
SF(x float64) float64
// LogSF is log SF(x) (scipy logsf).
LogSF(x float64) float64
// PPF is the quantile function, the inverse of CDF (scipy ppf).
PPF(p float64) float64
// ISF is the inverse of SF: ISF(q) = PPF(1-q) without the rounding of
// 1-q (scipy isf).
ISF(q float64) float64
// Mean, Var, Std, Skew and Kurtosis (excess, Fisher's definition) are
// the moments SciPy's stats(moments="mvsk") returns; ±Inf or NaN where
// they do not exist, as in SciPy.
Mean() float64
Var() float64
Std() float64
Skew() float64
Kurtosis() float64
// Median is PPF(0.5), in closed form where there is one.
Median() float64
// Entropy is the differential entropy in nats (scipy entropy).
Entropy() float64
// Moment is the non-central moment E[X^n] (scipy moment(n)).
Moment(n int) float64
// Interval is the equal-tailed interval holding the given probability
// mass: (PPF((1-c)/2), PPF((1+c)/2)) (scipy interval(confidence)).
Interval(confidence float64) (lo, hi float64)
// Support is the closed interval outside which the density is zero
// (scipy support()).
Support() (lo, hi float64)
// Rvs draws random variates with the shape given by size (no size: a
// 0-d array), consuming g exactly as scipy rvs(size=size,
// random_state=g) consumes a numpy.random.Generator; see the package
// documentation for which distributions reproduce SciPy's draws bit
// for bit.
Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
// Validate returns an error wrapping ErrParam when a parameter is out
// of the distribution's domain.
Validate() error
}
Continuous is the method set every continuous distribution of this package has: the methods of a frozen scipy.stats.rv_continuous (scipy.stats.norm(loc, scale).pdf(x) is Normal{Loc: loc, Scale: scale}.PDF(x)).
Every distribution is a struct of its shape parameters plus Loc and Scale, with SciPy's meaning: if Y has the standard distribution (Loc 0, Scale 1), X = Loc + Scale·Y. Scale must be positive: the zero value of a distribution struct is not a valid distribution, and its methods return NaN, as SciPy does for out-of-domain parameters. The NewXxx constructors return an error instead, and Validate says what is wrong.
The methods are pure functions of the receiver, safe for concurrent use. To apply one to an array, use ndarray's Map: x.Map(d.CDF).
type CorrelationOptions ¶
type CorrelationOptions struct {
Alternative Alternative
}
CorrelationOptions are the options of Pearsonr, Spearmanr and Linregress. The zero value (or nil) is a two-sided test.
type Data ¶
Data is what the descriptive statistics, the tests and the fits take as observations: a []float64, or a go-ndarray array of any shape and dtype, read in row-major order and converted to float64. The input is never modified.
type DdofOptions ¶
type DdofOptions struct {
// Ddof is the delta degrees of freedom of the standard deviation; nil
// means SciPy's default (1 for SEM, 0 for the others).
Ddof *float64
// OmitNaN ignores the NaNs (nan_policy="omit"); by default a NaN gives
// NaN.
OmitNaN bool
}
DdofOptions are the options of SEM, Variation, ZScore and ZMap.
type DescribeResult ¶
type DescribeResult struct {
NObs int
Min, Max float64
Mean, Variance float64
Skewness, Kurtosis float64
}
DescribeResult is scipy.stats.describe's result.
func Describe ¶
func Describe[D Data](x D, o *ShapeOptions) (DescribeResult, error)
Describe returns the count, extremes, mean, variance (ddof 1 by default), skewness and excess kurtosis of the data: scipy.stats.describe(x, ddof=Ddof, bias=!Unbiased). Pearson is ignored (SciPy reports Fisher's kurtosis).
type DiffEntropyMethod ¶
type DiffEntropyMethod int
DiffEntropyMethod is the estimator of DifferentialEntropy.
const ( // DiffEntropyAuto picks van Es for n <= 10, Ebrahimi for n <= 1000 and // Vasicek above (SciPy's method="auto"). DiffEntropyAuto DiffEntropyMethod = iota // DiffEntropyVasicek is method="vasicek". DiffEntropyVasicek // DiffEntropyVanEs is method="van es". DiffEntropyVanEs // DiffEntropyEbrahimi is method="ebrahimi". DiffEntropyEbrahimi // DiffEntropyCorrea is method="correa". DiffEntropyCorrea )
type DiffEntropyOptions ¶
type DiffEntropyOptions struct {
// WindowLength is the window m of the spacings; 0 means
// floor(sqrt(n) + 0.5), SciPy's default.
WindowLength int
// Base is the base of the logarithm; 0 means e (nats).
Base float64
// Method is the estimator (default DiffEntropyAuto).
Method DiffEntropyMethod
// OmitNaN ignores the NaNs; by default a NaN gives NaN.
OmitNaN bool
}
DiffEntropyOptions are the options of DifferentialEntropy.
type Dirichlet ¶
type Dirichlet struct {
// contains filtered or unexported fields
}
Dirichlet is the Dirichlet distribution on the (K-1)-simplex with concentration parameters Alpha (K of them, all positive): scipy.stats.dirichlet(alpha).
The log-density -log B(α) + Σ(αᵢ-1)·log xᵢ is summed in double-double, with double-double logarithms and, for α ≥ 30, double-double log-gamma values (Stirling's series): its terms nearly cancel when the concentrations are large, and SciPy, which sums float64 log-gamma values, loses their ULPs (about 4e-12 at α₀ = 3000).
func NewDirichlet ¶
NewDirichlet returns the Dirichlet distribution with the given concentrations. It returns an error wrapping ErrParam unless there are at least one and all are positive and finite.
func (*Dirichlet) Cov ¶
Cov returns the K×K covariance matrix (diag(a) - a·aᵀ)/(α₀+1) with a = α/α₀: scipy.stats.dirichlet.cov.
func (*Dirichlet) Entropy ¶
Entropy returns the differential entropy log B(α) + (α₀-K)ψ(α₀) - Σ(αᵢ-1)ψ(αᵢ): scipy.stats.dirichlet.entropy. The terms are summed in double-double (with double-double log-gamma and digamma values for large α), since they nearly cancel when the concentrations are large.
func (*Dirichlet) LogPDF ¶
LogPDF returns the log-density at x, given by its K coordinates or the first K-1 (the last is then 1 minus their sum): scipy.stats.dirichlet.logpdf. A point off the simplex is an error wrapping ErrData, as SciPy raises.
func (*Dirichlet) LogPDFPoints ¶
LogPDFPoints returns LogPDF at each row of x, an (n, K) or (n, K-1) array (a 1-D x is one point). SciPy's dirichlet takes the transpose, components along the first axis; here points are rows as everywhere in this package.
type Discrete ¶
type Discrete interface {
PMF(k float64) float64
LogPMF(k float64) float64
CDF(k float64) float64
LogCDF(k float64) float64
SF(k float64) float64
LogSF(k float64) float64
PPF(p float64) float64
ISF(q float64) float64
Mean() float64
Var() float64
Std() float64
Skew() float64
Kurtosis() float64
Median() float64
Entropy() float64
Moment(n int) float64
Interval(confidence float64) (lo, hi float64)
Support() (lo, hi float64)
Rvs(g *random.Generator, size ...int) (*ndarray.Array, error)
Validate() error
}
Discrete is the method set every discrete distribution of this package has: the methods of a frozen scipy.stats.rv_discrete (scipy.stats.binom(n, p, loc).pmf(k) is Binomial{N: n, P: p, Loc: loc}.PMF(k)).
Arguments and results are float64 so that the methods compose with ndarray's Map (k.Map(d.PMF)) as SciPy's do with arrays. PMF of a non-integer is 0; CDF and SF floor their argument; PPF and ISF return integers. Loc shifts the support. As with Continuous, out-of-domain parameters give NaN, and the NewXxx constructors and Validate an error.
type DiscreteUniform ¶
DiscreteUniform is the uniform distribution on the integers Low, Low+1, ..., High-1 (High excluded, High > Low): scipy.stats.randint(low, high, loc).
CDF and SF are the exact counts over High-Low, rounded once; their logarithms are differences of double-double logarithms of the counts.
func NewDiscreteUniform ¶
func NewDiscreteUniform(low int64, high int64, loc float64) (DiscreteUniform, error)
NewDiscreteUniform returns DiscreteUniform{Low: low, High: high, Loc: loc}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.randint(low, high, loc).
func (DiscreteUniform) CDF ¶
func (d DiscreteUniform) CDF(k float64) float64
CDF is P(X <= k): scipy.stats.randint.cdf(k, low, high, loc).
func (DiscreteUniform) Entropy ¶
func (d DiscreteUniform) Entropy() float64
Entropy is the Shannon entropy in nats: scipy.stats.randint.entropy(low, high, loc).
func (DiscreteUniform) ISF ¶
func (d DiscreteUniform) ISF(q float64) float64
ISF is the smallest k with SF(k) <= q: scipy.stats.randint.isf(q, low, high, loc).
func (DiscreteUniform) Interval ¶
func (d DiscreteUniform) Interval(confidence float64) (lo, hi float64)
Interval is the interval with the given probability mass between PPF((1-c)/2) and PPF((1+c)/2): scipy.stats.randint.interval(confidence, low, high, loc).
func (DiscreteUniform) Kurtosis ¶
func (d DiscreteUniform) Kurtosis() float64
Kurtosis is the excess kurtosis: scipy.stats.randint.stats(low, high, loc, moments="k").
func (DiscreteUniform) LogCDF ¶
func (d DiscreteUniform) LogCDF(k float64) float64
LogCDF is log P(X <= k): scipy.stats.randint.logcdf(k, low, high, loc).
func (DiscreteUniform) LogPMF ¶
func (d DiscreteUniform) LogPMF(k float64) float64
LogPMF is log P(X = k): scipy.stats.randint.logpmf(k, low, high, loc).
func (DiscreteUniform) LogSF ¶
func (d DiscreteUniform) LogSF(k float64) float64
LogSF is log P(X > k): scipy.stats.randint.logsf(k, low, high, loc).
func (DiscreteUniform) Mean ¶
func (d DiscreteUniform) Mean() float64
Mean is E[X]: scipy.stats.randint.mean(low, high, loc).
func (DiscreteUniform) Median ¶
func (d DiscreteUniform) Median() float64
Median is PPF(0.5): scipy.stats.randint.median(low, high, loc).
func (DiscreteUniform) Moment ¶
func (d DiscreteUniform) Moment(n int) float64
Moment is the non-central moment E[X^n]: scipy.stats.randint.moment(n, low, high, loc).
func (DiscreteUniform) PMF ¶
func (d DiscreteUniform) PMF(k float64) float64
PMF is the probability mass P(X = k), zero unless k - Loc is an integer in the support: scipy.stats.randint.pmf(k, low, high, loc).
func (DiscreteUniform) PPF ¶
func (d DiscreteUniform) PPF(p float64) float64
PPF is the smallest k with CDF(k) >= p: scipy.stats.randint.ppf(p, low, high, loc).
func (DiscreteUniform) Rvs ¶
Rvs draws random variates of the given shape as an int64 array: scipy.stats.randint.rvs(low, high, loc, size=size, random_state=g).
func (DiscreteUniform) SF ¶
func (d DiscreteUniform) SF(k float64) float64
SF is P(X > k): scipy.stats.randint.sf(k, low, high, loc).
func (DiscreteUniform) Skew ¶
func (d DiscreteUniform) Skew() float64
Skew is the skewness: scipy.stats.randint.stats(low, high, loc, moments="s").
func (DiscreteUniform) Std ¶
func (d DiscreteUniform) Std() float64
Std is the standard deviation: scipy.stats.randint.std(low, high, loc).
func (DiscreteUniform) Support ¶
func (d DiscreteUniform) Support() (lo, hi float64)
Support is the smallest and largest value with positive mass: scipy.stats.randint.support(low, high, loc).
func (DiscreteUniform) Validate ¶
func (d DiscreteUniform) Validate() error
Validate returns an error wrapping ErrParam unless Loc is finite and the shape parameters are in their domain.
func (DiscreteUniform) Var ¶
func (d DiscreteUniform) Var() float64
Var is the variance: scipy.stats.randint.var(low, high, loc).
type EntropyOptions ¶
type EntropyOptions struct {
// QK, when not nil, is the second distribution: the result is then the
// relative entropy (Kullback-Leibler divergence) of pk from qk.
QK []float64
// Base is the base of the logarithm; 0 means e (nats).
Base float64
}
EntropyOptions are the options of Entropy.
type Exponential ¶
type Exponential struct {
Loc, Scale float64
}
Exponential is the exponential distribution with rate 1/Scale, shifted by Loc: density exp(-x) on [0, ∞) in standard form: scipy.stats.expon(loc, scale).
Every function is carried in double-double and rounded once: the density and SF are exp(-x) (dd.Exp), CDF is -expm1(-x), LogCDF log1p(-exp(-x)) or log(-expm1(-x)) whichever does not cancel, PPF -log1p(-p) and ISF -log(q).
func FitExponential ¶
func FitExponential[D Data](x D, o *FitOptions) (Exponential, error)
FitExponential returns the maximum-likelihood exponential distribution for x: Loc the minimum and Scale the mean excess over it, or the other one when Loc or Scale is fixed: scipy.stats.expon.fit(x, floc=, fscale=). The result is SciPy's to the bit.
func NewExponential ¶
func NewExponential(loc, scale float64) (Exponential, error)
NewExponential returns Exponential{Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.expon(loc, scale).
func (Exponential) CDF ¶
func (d Exponential) CDF(x float64) float64
CDF is P(X <= x): scipy.stats.expon.cdf(x, loc, scale).
func (Exponential) Entropy ¶
func (d Exponential) Entropy() float64
Entropy is the differential entropy in nats: scipy.stats.expon.entropy(loc, scale).
func (Exponential) ISF ¶
func (d Exponential) ISF(q float64) float64
ISF is the inverse of SF: scipy.stats.expon.isf(q, loc, scale).
func (Exponential) Interval ¶
func (d Exponential) Interval(confidence float64) (lo, hi float64)
Interval is the equal-tailed interval with the given probability mass: scipy.stats.expon.interval(confidence, loc, scale).
func (Exponential) Kurtosis ¶
func (d Exponential) Kurtosis() float64
Kurtosis is the excess kurtosis: scipy.stats.expon.stats(loc, scale, moments="k").
func (Exponential) LogCDF ¶
func (d Exponential) LogCDF(x float64) float64
LogCDF is log P(X <= x): scipy.stats.expon.logcdf(x, loc, scale).
func (Exponential) LogPDF ¶
func (d Exponential) LogPDF(x float64) float64
LogPDF is the logarithm of the density at x: scipy.stats.expon.logpdf(x, loc, scale).
func (Exponential) LogSF ¶
func (d Exponential) LogSF(x float64) float64
LogSF is log P(X > x): scipy.stats.expon.logsf(x, loc, scale).
func (Exponential) Mean ¶
func (d Exponential) Mean() float64
Mean is E[X]: scipy.stats.expon.mean(loc, scale).
func (Exponential) Median ¶
func (d Exponential) Median() float64
Median is the median: scipy.stats.expon.median(loc, scale).
func (Exponential) Moment ¶
func (d Exponential) Moment(n int) float64
Moment is the non-central moment E[X^n]: scipy.stats.expon.moment(n, loc, scale).
func (Exponential) PDF ¶
func (d Exponential) PDF(x float64) float64
PDF is the probability density at x: scipy.stats.expon.pdf(x, loc, scale).
func (Exponential) PPF ¶
func (d Exponential) PPF(p float64) float64
PPF is the quantile function, the inverse of CDF: scipy.stats.expon.ppf(p, loc, scale).
func (Exponential) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.expon.rvs(loc, scale, size=size, random_state=g).
func (Exponential) SF ¶
func (d Exponential) SF(x float64) float64
SF is the survival function P(X > x): scipy.stats.expon.sf(x, loc, scale).
func (Exponential) Skew ¶
func (d Exponential) Skew() float64
Skew is the skewness: scipy.stats.expon.stats(loc, scale, moments="s").
func (Exponential) Std ¶
func (d Exponential) Std() float64
Std is the standard deviation: scipy.stats.expon.std(loc, scale).
func (Exponential) Support ¶
func (d Exponential) Support() (lo, hi float64)
Support is the interval where the density is positive: scipy.stats.expon.support(loc, scale).
func (Exponential) Validate ¶
func (d Exponential) Validate() error
Validate returns an error wrapping ErrParam unless Scale is positive and finite, Loc finite and the shape parameters in their domain.
func (Exponential) Var ¶
func (d Exponential) Var() float64
Var is the variance: scipy.stats.expon.var(loc, scale).
type F ¶
type F struct {
Dfn, Dfd, Loc, Scale float64
}
F is Fisher's F distribution (the variance ratio) with Dfn and Dfd degrees of freedom: scipy.stats.f(dfn, dfd, loc, scale).
With v = Dfn·x, the distribution functions are I_{v/(Dfd+v)}(Dfn/2, Dfd/2) or its complement through I_{Dfd/(Dfd+v)}(Dfd/2, Dfn/2), the argument chosen below 1/2 as Boost does; the quantile inverts the incomplete beta function for x or 1-x, whichever is small, and the density is the beta density at the same argument times the Jacobian.
func FitF ¶
func FitF[D Data](x D, o *FitOptions) (F, error)
FitF returns the maximum-likelihood F distribution for x: scipy.stats.f.fit(x, fdfn=, fdfd=, floc=, fscale=), numerically from SciPy's starting point.
func NewF ¶
NewF returns F{Dfn: dfn, Dfd: dfd, Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.f(dfn, dfd, loc, scale).
func (F) Entropy ¶
Entropy is the differential entropy in nats: scipy.stats.f.entropy(dfn, dfd, loc, scale).
func (F) Interval ¶
Interval is the equal-tailed interval with the given probability mass: scipy.stats.f.interval(confidence, dfn, dfd, loc, scale).
func (F) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.f.stats(dfn, dfd, loc, scale, moments="k").
func (F) LogPDF ¶
LogPDF is the logarithm of the density at x: scipy.stats.f.logpdf(x, dfn, dfd, loc, scale).
func (F) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.f.moment(n, dfn, dfd, loc, scale).
func (F) PPF ¶
PPF is the quantile function, the inverse of CDF: scipy.stats.f.ppf(p, dfn, dfd, loc, scale).
func (F) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.f.rvs(dfn, dfd, loc, scale, size=size, random_state=g).
func (F) Support ¶
Support is the interval where the density is positive: scipy.stats.f.support(dfn, dfd, loc, scale).
type FOnewayOptions ¶
type FOnewayOptions struct {
// Welch selects Welch's heteroscedastic ANOVA (SciPy's
// equal_var=False).
Welch bool
}
FOnewayOptions are the options of FOneway. The zero value (or nil) is SciPy's default: the classical one-way ANOVA assuming equal variances.
type FisherExactOptions ¶
type FisherExactOptions struct {
Alternative Alternative
}
FisherExactOptions are the options of FisherExact. The zero value (or nil) is a two-sided test.
type FitOptions ¶
type FitOptions struct {
// Fixed holds parameters that are not estimated but held at the given
// value, by struct field name: {"Loc": 0} is SciPy's floc=0,
// {"Scale": 2} fscale=2, {"A": 1.5} fa=1.5 (or f0=1.5).
Fixed map[string]float64
}
FitOptions configures the FitXxx functions.
type FreqOptions ¶
type FreqOptions struct {
// NumBins is the number of bins (0 means 10).
NumBins int
// Limits, when not nil, are the lower and upper limits of the bins
// (SciPy's defaultreallimits=); by default the data's range widened by
// half a bin at each end.
Limits *[2]float64
// Weights, when not nil, weight the observations.
Weights []float64
}
FreqOptions are the options of CumFreq and RelFreq.
type FreqResult ¶
type FreqResult struct {
// Freq are the cumulative counts (CumFreq) or relative frequencies
// (RelFreq) of the bins.
Freq []float64
// LowerLimit is the lower limit of the first bin.
LowerLimit float64
// BinSize is the width of the bins.
BinSize float64
// ExtraPoints counts the observations outside the bins.
ExtraPoints int
}
FreqResult is the result of scipy.stats.cumfreq and relfreq.
func CumFreq ¶
func CumFreq[D Data](x D, o *FreqOptions) (FreqResult, error)
CumFreq returns the cumulative frequency histogram: scipy.stats.cumfreq(x, numbins, defaultreallimits, weights).
func RelFreq ¶
func RelFreq[D Data](x D, o *FreqOptions) (FreqResult, error)
RelFreq returns the relative frequency histogram: scipy.stats.relfreq(x, numbins, defaultreallimits, weights).
type Gamma ¶
type Gamma struct {
A, Loc, Scale float64
}
Gamma is the gamma distribution with shape A: density x^(A-1) e^(-x) / Γ(A) in standard form: scipy.stats.gamma(a, loc, scale).
CDF and SF are special.GammaP and special.GammaQ, PPF and ISF their inverses. The density carries its exponent in double-double and, for A >= 30, takes Stirling's factors out analytically (see gammaExponent), where SciPy's exp(xlogy(a-1, x) - x - gammaln(a)) loses about log2(A) bits to cancellation.
func FitGamma ¶
func FitGamma[D Data](x D, o *FitOptions) (Gamma, error)
FitGamma returns the maximum-likelihood gamma distribution for x: scipy.stats.gamma.fit(x, fa=, floc=, fscale=). With Loc fixed it solves the likelihood equations as SciPy does (log a - ψ(a) = log x̄ - mean log x, then Scale = x̄/A); otherwise it maximises the likelihood numerically from SciPy's starting point, to a tighter optimum than SciPy's fmin reaches.
func NewGamma ¶
NewGamma returns Gamma{A: a, Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.gamma(a, loc, scale).
func (Gamma) Entropy ¶
Entropy is the differential entropy in nats: scipy.stats.gamma.entropy(a, loc, scale).
func (Gamma) Interval ¶
Interval is the equal-tailed interval with the given probability mass: scipy.stats.gamma.interval(confidence, a, loc, scale).
func (Gamma) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.gamma.stats(a, loc, scale, moments="k").
func (Gamma) LogPDF ¶
LogPDF is the logarithm of the density at x: scipy.stats.gamma.logpdf(x, a, loc, scale).
func (Gamma) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.gamma.moment(n, a, loc, scale).
func (Gamma) PPF ¶
PPF is the quantile function, the inverse of CDF: scipy.stats.gamma.ppf(p, a, loc, scale).
func (Gamma) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.gamma.rvs(a, loc, scale, size=size, random_state=g).
func (Gamma) Support ¶
Support is the interval where the density is positive: scipy.stats.gamma.support(a, loc, scale).
type GaussianKDE ¶
type GaussianKDE struct {
// contains filtered or unexported fields
}
GaussianKDE is a kernel density estimate with Gaussian kernels: scipy.stats.gaussian_kde(dataset, bw_method, weights).
The kernel covariance is the weighted data covariance times factor². Evaluation whitens the data and the points by the Cholesky factor of the kernel covariance, as SciPy does, but sums each estimate with compensated (Neumaier) summation, relative to its largest term, so the density and its logarithm are accurate to about one ULP of the computed kernel values and the logarithm stays finite far from the data. In one dimension the data are sorted once and each estimate sums only the points whose kernel exceeds 2^-60 of the nearest point's (the omitted terms together are below 2^-60 of the result). Points are evaluated in parallel; each result is computed by one goroutine in a fixed order, so results do not depend on GOMAXPROCS.
func NewGaussianKDE ¶
func NewGaussianKDE[D Data](dataset D, o *GaussianKDEOptions) (*GaussianKDE, error)
NewGaussianKDE returns the kernel density estimate of dataset: a []float64 (one-dimensional data), a 1-D array, or a d×n array with one row per dimension and one column per point (SciPy's layout). It returns an error wrapping ErrData when there are fewer than two values, more dimensions than points, or the data lie in a lower-dimensional subspace (their covariance is singular), and ErrParam for invalid weights or bandwidth.
func (*GaussianKDE) ChoCov ¶
func (k *GaussianKDE) ChoCov() *ndarray.Array
ChoCov returns the lower Cholesky factor of the kernel covariance (SciPy's cho_cov), d×d.
func (*GaussianKDE) Covariance ¶
func (k *GaussianKDE) Covariance() *ndarray.Array
Covariance returns the kernel covariance, the data covariance times factor², d×d.
func (*GaussianKDE) Dataset ¶
func (k *GaussianKDE) Dataset() *ndarray.Array
Dataset returns the data, d×n (a copy).
func (*GaussianKDE) Evaluate ¶
func (k *GaussianKDE) Evaluate(points *ndarray.Array) ([]float64, error)
Evaluate returns the estimated density at each point: scipy.stats.gaussian_kde.evaluate (also pdf and __call__). Points are read as SciPy reads them: a d×m array, one column per point, or a 1-D array (m points when d is 1, else one point).
func (*GaussianKDE) EvaluateSlice ¶
func (k *GaussianKDE) EvaluateSlice(x []float64) ([]float64, error)
EvaluateSlice is Evaluate for points given as a []float64, read as a 1-D array.
func (*GaussianKDE) Factor ¶
func (k *GaussianKDE) Factor() float64
Factor returns the bandwidth factor.
func (*GaussianKDE) IntegrateBox ¶
func (k *GaussianKDE) IntegrateBox(low, high []float64, o *MultivariateNormalCDFOptions) (float64, error)
IntegrateBox returns the integral of the estimate over the box [low, high]: scipy.stats.gaussian_kde.integrate_box, with the multivariate normal cdf of each kernel (MultivariateNormal.CDF, options as there; one generator serves every kernel in turn, as in SciPy).
func (*GaussianKDE) IntegrateBox1D ¶
func (k *GaussianKDE) IntegrateBox1D(low, high float64) (float64, error)
IntegrateBox1D returns the integral of the one-dimensional estimate over [low, high]: scipy.stats.gaussian_kde.integrate_box_1d. Each kernel's mass is a difference of normal cdfs, or of survival functions above its centre, so that tail intervals keep their relative accuracy.
func (*GaussianKDE) IntegrateGaussian ¶
IntegrateGaussian returns the integral of the product of the estimate and the normal density with the given mean and covariance (d×d): scipy.stats.gaussian_kde.integrate_gaussian.
func (*GaussianKDE) IntegrateKDE ¶
func (k *GaussianKDE) IntegrateKDE(other *GaussianKDE) (float64, error)
IntegrateKDE returns the integral of the product of two estimates of the same dimension: scipy.stats.gaussian_kde.integrate_kde.
func (*GaussianKDE) InvCov ¶
func (k *GaussianKDE) InvCov() *ndarray.Array
InvCov returns the inverse of the kernel covariance, d×d (SciPy's inv_cov).
func (*GaussianKDE) LogDet ¶
func (k *GaussianKDE) LogDet() float64
LogDet returns SciPy's log_det, 2·Σ log(Lᵢᵢ·√(2π)) = log det(2πΣ).
func (*GaussianKDE) LogPDF ¶
func (k *GaussianKDE) LogPDF(points *ndarray.Array) ([]float64, error)
LogPDF returns the logarithm of the estimated density at each point (see Evaluate): scipy.stats.gaussian_kde.logpdf. It is computed relative to the largest kernel term, so it is finite and accurate far from the data, where the density underflows.
func (*GaussianKDE) LogPDFSlice ¶
func (k *GaussianKDE) LogPDFSlice(x []float64) ([]float64, error)
LogPDFSlice is LogPDF for points given as a []float64, read as a 1-D array.
func (*GaussianKDE) Marginal ¶
func (k *GaussianKDE) Marginal(dims ...int) (*GaussianKDE, error)
Marginal returns the estimate of the marginal distribution of the given dimensions (indices, negative ones counting from the end), with the same bandwidth factor and weights: scipy.stats.gaussian_kde.marginal.
func (*GaussianKDE) Neff ¶
func (k *GaussianKDE) Neff() float64
Neff returns the effective number of points, 1/Σw².
func (*GaussianKDE) Resample ¶
Resample draws size points from the estimate, a d×size array, as scipy.stats.gaussian_kde.resample(size, seed=g) does: first Generator.multivariate_normal(zeros(d), covariance, size), then Generator.choice(n, size, p=weights), and the chosen data points plus the normal draws. size 0 is int(neff), SciPy's default. The draws are SciPy's bit for bit in one dimension; in more, the normal parts agree to a few ULP (see MultivariateNormal.Rvs).
func (*GaussianKDE) ScottsFactor ¶
func (k *GaussianKDE) ScottsFactor() float64
ScottsFactor returns neff^(-1/(d+4)).
func (*GaussianKDE) SetBandwidth ¶
func (k *GaussianKDE) SetBandwidth(b KDEBandwidth) error
SetBandwidth changes the bandwidth factor and recomputes the kernel covariance: scipy.stats.gaussian_kde.set_bandwidth. It returns an error wrapping ErrParam if the factor is not positive and finite.
func (*GaussianKDE) SilvermanFactor ¶
func (k *GaussianKDE) SilvermanFactor() float64
SilvermanFactor returns (neff·(d+2)/4)^(-1/(d+4)).
func (*GaussianKDE) Weights ¶
func (k *GaussianKDE) Weights() []float64
Weights returns the normalized weights (a copy).
type GaussianKDEOptions ¶
type GaussianKDEOptions struct {
Bandwidth KDEBandwidth
// Weights are the weights of the data points (n of them, nonnegative,
// not all zero); nil is equal weights. They are normalized to sum to 1.
Weights []float64
}
GaussianKDEOptions configures NewGaussianKDE. The zero value is SciPy's default: Scott's rule and equal weights.
type Geometric ¶
type Geometric struct {
P, Loc float64
}
Geometric is the number of trials up to and including the first success, each of probability P in (0, 1]: mass (1-P)^(k-1) P on k = 1, 2, ...: scipy.stats.geom(p, loc).
Every function is a closed form in k·log(1-P), carried in double-double (log1p(-P) to 2^-70 relative, the product exact) before one exponential: SF is exp(k log(1-P)), CDF -expm1 of it, LogCDF log(-expm1) or log1p(-exp), so that they stay accurate for P near 0 and k near 2^53.
func NewGeometric ¶
NewGeometric returns Geometric{P: p, Loc: loc}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.geom(p, loc).
func (Geometric) Entropy ¶
Entropy is the Shannon entropy in nats: scipy.stats.geom.entropy(p, loc).
func (Geometric) Interval ¶
Interval is the interval with the given probability mass between PPF((1-c)/2) and PPF((1+c)/2): scipy.stats.geom.interval(confidence, p, loc).
func (Geometric) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.geom.stats(p, loc, moments="k").
func (Geometric) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.geom.moment(n, p, loc).
func (Geometric) PMF ¶
PMF is the probability mass P(X = k), zero unless k - Loc is an integer in the support: scipy.stats.geom.pmf(k, p, loc).
func (Geometric) Rvs ¶
Rvs draws random variates of the given shape as an int64 array: scipy.stats.geom.rvs(p, loc, size=size, random_state=g).
func (Geometric) Support ¶
Support is the smallest and largest value with positive mass: scipy.stats.geom.support(p, loc).
type Gumbel ¶
type Gumbel struct {
Loc, Scale float64
}
Gumbel is the (right-skewed) Gumbel distribution, the type I extreme value distribution of maxima: density exp(-(x + e^(-x))) in standard form: scipy.stats.gumbel_r(loc, scale).
e = exp(-x) is carried in double-double: the density is exp(-x - e), CDF exp(-e), SF -expm1(-e), LogSF log(1 - exp(-e)) in the form that does not cancel (SciPy's log(sf) loses everything where SF is near 1), each rounded once; PPF -log(-log p) and ISF -log(-log1p(-q)) take the inner logarithm in double-double.
func FitGumbel ¶
func FitGumbel[D Data](x D, o *FitOptions) (Gumbel, error)
FitGumbel returns the maximum-likelihood Gumbel distribution for x: scipy.stats.gumbel_r.fit(x, floc=, fscale=). It solves SciPy's likelihood equations: with Scale fixed, Loc = -Scale·log(mean exp(-x/Scale)) in closed form; otherwise Scale is the root of SciPy's equation (bracketed as SciPy brackets it, from 1) found to full precision, and Loc follows.
func NewGumbel ¶
NewGumbel returns Gumbel{Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.gumbel_r(loc, scale).
func (Gumbel) Entropy ¶
Entropy is the differential entropy in nats: scipy.stats.gumbel_r.entropy(loc, scale).
func (Gumbel) Interval ¶
Interval is the equal-tailed interval with the given probability mass: scipy.stats.gumbel_r.interval(confidence, loc, scale).
func (Gumbel) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.gumbel_r.stats(loc, scale, moments="k").
func (Gumbel) LogPDF ¶
LogPDF is the logarithm of the density at x: scipy.stats.gumbel_r.logpdf(x, loc, scale).
func (Gumbel) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.gumbel_r.moment(n, loc, scale).
func (Gumbel) PPF ¶
PPF is the quantile function, the inverse of CDF: scipy.stats.gumbel_r.ppf(p, loc, scale).
func (Gumbel) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.gumbel_r.rvs(loc, scale, size=size, random_state=g).
func (Gumbel) Support ¶
Support is the interval where the density is positive: scipy.stats.gumbel_r.support(loc, scale).
type HalfNormal ¶
type HalfNormal struct {
Loc, Scale float64
}
HalfNormal is the half-normal distribution, |Z| for standard normal Z: density √(2/π) exp(-x²/2) on [0, ∞) in standard form: scipy.stats.halfnorm(loc, scale).
The density carries x²/2 exactly; SF is 2Φ(-x) and CDF erf(x/√2) with the rounding of x/√2 corrected to first order, or 1 - SF beyond 1. PPF is √2·erfinv(p) below 1/2 (SciPy's Φ⁻¹((1+p)/2) loses every bit of p below 1e-16) and -Φ⁻¹((1-p)/2) above, both exact in their argument.
func FitHalfNormal ¶
func FitHalfNormal[D Data](x D, o *FitOptions) (HalfNormal, error)
FitHalfNormal returns the maximum-likelihood half-normal distribution for x: Loc the minimum and Scale the root mean square of x - Loc, or the other one when Loc or Scale is fixed: scipy.stats.halfnorm.fit(x, floc=, fscale=). The result is SciPy's to the bit.
func NewHalfNormal ¶
func NewHalfNormal(loc, scale float64) (HalfNormal, error)
NewHalfNormal returns HalfNormal{Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.halfnorm(loc, scale).
func (HalfNormal) CDF ¶
func (d HalfNormal) CDF(x float64) float64
CDF is P(X <= x): scipy.stats.halfnorm.cdf(x, loc, scale).
func (HalfNormal) Entropy ¶
func (d HalfNormal) Entropy() float64
Entropy is the differential entropy in nats: scipy.stats.halfnorm.entropy(loc, scale).
func (HalfNormal) ISF ¶
func (d HalfNormal) ISF(q float64) float64
ISF is the inverse of SF: scipy.stats.halfnorm.isf(q, loc, scale).
func (HalfNormal) Interval ¶
func (d HalfNormal) Interval(confidence float64) (lo, hi float64)
Interval is the equal-tailed interval with the given probability mass: scipy.stats.halfnorm.interval(confidence, loc, scale).
func (HalfNormal) Kurtosis ¶
func (d HalfNormal) Kurtosis() float64
Kurtosis is the excess kurtosis: scipy.stats.halfnorm.stats(loc, scale, moments="k").
func (HalfNormal) LogCDF ¶
func (d HalfNormal) LogCDF(x float64) float64
LogCDF is log P(X <= x): scipy.stats.halfnorm.logcdf(x, loc, scale).
func (HalfNormal) LogPDF ¶
func (d HalfNormal) LogPDF(x float64) float64
LogPDF is the logarithm of the density at x: scipy.stats.halfnorm.logpdf(x, loc, scale).
func (HalfNormal) LogSF ¶
func (d HalfNormal) LogSF(x float64) float64
LogSF is log P(X > x): scipy.stats.halfnorm.logsf(x, loc, scale).
func (HalfNormal) Mean ¶
func (d HalfNormal) Mean() float64
Mean is E[X]: scipy.stats.halfnorm.mean(loc, scale).
func (HalfNormal) Median ¶
func (d HalfNormal) Median() float64
Median is the median: scipy.stats.halfnorm.median(loc, scale).
func (HalfNormal) Moment ¶
func (d HalfNormal) Moment(n int) float64
Moment is the non-central moment E[X^n]: scipy.stats.halfnorm.moment(n, loc, scale).
func (HalfNormal) PDF ¶
func (d HalfNormal) PDF(x float64) float64
PDF is the probability density at x: scipy.stats.halfnorm.pdf(x, loc, scale).
func (HalfNormal) PPF ¶
func (d HalfNormal) PPF(p float64) float64
PPF is the quantile function, the inverse of CDF: scipy.stats.halfnorm.ppf(p, loc, scale).
func (HalfNormal) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.halfnorm.rvs(loc, scale, size=size, random_state=g).
func (HalfNormal) SF ¶
func (d HalfNormal) SF(x float64) float64
SF is the survival function P(X > x): scipy.stats.halfnorm.sf(x, loc, scale).
func (HalfNormal) Skew ¶
func (d HalfNormal) Skew() float64
Skew is the skewness: scipy.stats.halfnorm.stats(loc, scale, moments="s").
func (HalfNormal) Std ¶
func (d HalfNormal) Std() float64
Std is the standard deviation: scipy.stats.halfnorm.std(loc, scale).
func (HalfNormal) Support ¶
func (d HalfNormal) Support() (lo, hi float64)
Support is the interval where the density is positive: scipy.stats.halfnorm.support(loc, scale).
func (HalfNormal) Validate ¶
func (d HalfNormal) Validate() error
Validate returns an error wrapping ErrParam unless Scale is positive and finite, Loc finite and the shape parameters in their domain.
func (HalfNormal) Var ¶
func (d HalfNormal) Var() float64
Var is the variance: scipy.stats.halfnorm.var(loc, scale).
type HistogramOptions ¶
type HistogramOptions struct {
// Bins is the number of equal-width bins (0 means 10).
Bins int
// Edges, when not nil, are the bin edges (non-decreasing); they take
// precedence over Bins and Rule.
Edges []float64
// Rule, when not BinsCount, estimates the bin width from the data.
Rule BinRule
// Range, when not nil, is the (finite) range of the equal-width bins;
// observations outside it (and NaNs) are ignored. By default the
// data's minimum and maximum.
Range *[2]float64
// Density normalises the counts to a probability density.
Density bool
// Weights, when not nil, weight the observations.
Weights []float64
}
HistogramOptions are the options of Histogram and HistogramBinEdges. The zero value is NumPy's default: 10 equal bins over the data's range.
type HistogramResult ¶
type HistogramResult struct {
// Counts are the (weighted) counts, or densities, of the bins.
Counts []float64
// Edges are the len(Counts)+1 bin edges.
Edges []float64
}
HistogramResult is numpy.histogram's result.
func Histogram ¶
func Histogram[D Data](x D, o *HistogramOptions) (HistogramResult, error)
Histogram returns the (weighted) counts of the data in bins and the bin edges: numpy.histogram(x, bins, range, density, weights), to the bit. Each bin is half-open [a, b) but the last, which is closed.
type Hypergeometric ¶
Hypergeometric is the number of good items among Draws drawn without replacement from Total items of which Good are good: mass C(Good,k) C(Total-Good, Draws-k) / C(Total, Draws): scipy.stats.hypergeom(M, n, N, loc) with M = Total, n = Good, N = Draws.
PMF is R's dhyper: the product of two binomial masses over a third, all at p = Draws/Total, in Loader's form (see binomTerm) with the three exponents combined in double-double before one exponential. CDF and SF sum the masses of a tail from its first one by the ratio of successive masses (in double-double), starting with the tail on k's side of the mean and switching to the other when that one turns out to be the smaller: the cost is proportional to the standard deviation, and the logarithms (log of the first mass plus log of the scaled sum) stay accurate where the probabilities underflow.
func NewHypergeometric ¶
NewHypergeometric returns Hypergeometric{Total: M, Good: n, Draws: N, Loc: loc}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.hypergeom(M, n, N, loc).
func (Hypergeometric) CDF ¶
func (d Hypergeometric) CDF(k float64) float64
CDF is P(X <= k): scipy.stats.hypergeom.cdf(k, M, n, N, loc).
func (Hypergeometric) Entropy ¶
func (d Hypergeometric) Entropy() float64
Entropy is the Shannon entropy in nats: scipy.stats.hypergeom.entropy(M, n, N, loc).
func (Hypergeometric) ISF ¶
func (d Hypergeometric) ISF(q float64) float64
ISF is the smallest k with SF(k) <= q: scipy.stats.hypergeom.isf(q, M, n, N, loc).
func (Hypergeometric) Interval ¶
func (d Hypergeometric) Interval(confidence float64) (lo, hi float64)
Interval is the interval with the given probability mass between PPF((1-c)/2) and PPF((1+c)/2): scipy.stats.hypergeom.interval(confidence, M, n, N, loc).
func (Hypergeometric) Kurtosis ¶
func (d Hypergeometric) Kurtosis() float64
Kurtosis is the excess kurtosis: scipy.stats.hypergeom.stats(M, n, N, loc, moments="k").
func (Hypergeometric) LogCDF ¶
func (d Hypergeometric) LogCDF(k float64) float64
LogCDF is log P(X <= k): scipy.stats.hypergeom.logcdf(k, M, n, N, loc).
func (Hypergeometric) LogPMF ¶
func (d Hypergeometric) LogPMF(k float64) float64
LogPMF is log P(X = k): scipy.stats.hypergeom.logpmf(k, M, n, N, loc).
func (Hypergeometric) LogSF ¶
func (d Hypergeometric) LogSF(k float64) float64
LogSF is log P(X > k): scipy.stats.hypergeom.logsf(k, M, n, N, loc).
func (Hypergeometric) Mean ¶
func (d Hypergeometric) Mean() float64
Mean is E[X]: scipy.stats.hypergeom.mean(M, n, N, loc).
func (Hypergeometric) Median ¶
func (d Hypergeometric) Median() float64
Median is PPF(0.5): scipy.stats.hypergeom.median(M, n, N, loc).
func (Hypergeometric) Moment ¶
func (d Hypergeometric) Moment(n int) float64
Moment is the non-central moment E[X^n]: scipy.stats.hypergeom.moment(n, M, n, N, loc).
func (Hypergeometric) PMF ¶
func (d Hypergeometric) PMF(k float64) float64
PMF is the probability mass P(X = k), zero unless k - Loc is an integer in the support: scipy.stats.hypergeom.pmf(k, M, n, N, loc).
func (Hypergeometric) PPF ¶
func (d Hypergeometric) PPF(p float64) float64
PPF is the smallest k with CDF(k) >= p: scipy.stats.hypergeom.ppf(p, M, n, N, loc).
func (Hypergeometric) Rvs ¶
Rvs draws random variates of the given shape as an int64 array: scipy.stats.hypergeom.rvs(M, n, N, loc, size=size, random_state=g).
func (Hypergeometric) SF ¶
func (d Hypergeometric) SF(k float64) float64
SF is P(X > k): scipy.stats.hypergeom.sf(k, M, n, N, loc).
func (Hypergeometric) Skew ¶
func (d Hypergeometric) Skew() float64
Skew is the skewness: scipy.stats.hypergeom.stats(M, n, N, loc, moments="s").
func (Hypergeometric) Std ¶
func (d Hypergeometric) Std() float64
Std is the standard deviation: scipy.stats.hypergeom.std(M, n, N, loc).
func (Hypergeometric) Support ¶
func (d Hypergeometric) Support() (lo, hi float64)
Support is the smallest and largest value with positive mass: scipy.stats.hypergeom.support(M, n, N, loc).
func (Hypergeometric) Validate ¶
func (d Hypergeometric) Validate() error
Validate returns an error wrapping ErrParam unless Loc is finite and the shape parameters are in their domain.
func (Hypergeometric) Var ¶
func (d Hypergeometric) Var() float64
Var is the variance: scipy.stats.hypergeom.var(M, n, N, loc).
type IQROptions ¶
type IQROptions struct {
// Range is the pair of percentiles (SciPy's rng=); the zero value
// means (25, 75).
Range [2]float64
// Scale divides the result (0 means 1); IQRNormal is scale="normal".
Scale float64
// Method is the quantile estimator (SciPy's interpolation=), computed
// as scipy.stats.quantile does.
Method QuantileMethod
// OmitNaN ignores the NaNs; by default a NaN gives NaN.
OmitNaN bool
}
IQROptions are the options of IQR.
type InverseGamma ¶
type InverseGamma struct {
A, Loc, Scale float64
}
InverseGamma is the distribution of 1/Y for Y gamma with shape A: scipy.stats.invgamma(a, loc, scale). CDF(x) = Q(A, 1/x), SF = P(A, 1/x), PPF(p) = 1/Q⁻¹(A, p); the density is the gamma density at 1/x over x².
func FitInverseGamma ¶
func FitInverseGamma[D Data](x D, o *FitOptions) (InverseGamma, error)
FitInverseGamma returns the maximum-likelihood inverse gamma distribution for x: scipy.stats.invgamma.fit(x, fa=, floc=, fscale=), numerically from SciPy's starting point.
func NewInverseGamma ¶
func NewInverseGamma(a float64, loc, scale float64) (InverseGamma, error)
NewInverseGamma returns InverseGamma{A: a, Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.invgamma(a, loc, scale).
func (InverseGamma) CDF ¶
func (d InverseGamma) CDF(x float64) float64
CDF is P(X <= x): scipy.stats.invgamma.cdf(x, a, loc, scale).
func (InverseGamma) Entropy ¶
func (d InverseGamma) Entropy() float64
Entropy is the differential entropy in nats: scipy.stats.invgamma.entropy(a, loc, scale).
func (InverseGamma) ISF ¶
func (d InverseGamma) ISF(q float64) float64
ISF is the inverse of SF: scipy.stats.invgamma.isf(q, a, loc, scale).
func (InverseGamma) Interval ¶
func (d InverseGamma) Interval(confidence float64) (lo, hi float64)
Interval is the equal-tailed interval with the given probability mass: scipy.stats.invgamma.interval(confidence, a, loc, scale).
func (InverseGamma) Kurtosis ¶
func (d InverseGamma) Kurtosis() float64
Kurtosis is the excess kurtosis: scipy.stats.invgamma.stats(a, loc, scale, moments="k").
func (InverseGamma) LogCDF ¶
func (d InverseGamma) LogCDF(x float64) float64
LogCDF is log P(X <= x): scipy.stats.invgamma.logcdf(x, a, loc, scale).
func (InverseGamma) LogPDF ¶
func (d InverseGamma) LogPDF(x float64) float64
LogPDF is the logarithm of the density at x: scipy.stats.invgamma.logpdf(x, a, loc, scale).
func (InverseGamma) LogSF ¶
func (d InverseGamma) LogSF(x float64) float64
LogSF is log P(X > x): scipy.stats.invgamma.logsf(x, a, loc, scale).
func (InverseGamma) Mean ¶
func (d InverseGamma) Mean() float64
Mean is E[X]: scipy.stats.invgamma.mean(a, loc, scale).
func (InverseGamma) Median ¶
func (d InverseGamma) Median() float64
Median is the median: scipy.stats.invgamma.median(a, loc, scale).
func (InverseGamma) Moment ¶
func (d InverseGamma) Moment(n int) float64
Moment is the non-central moment E[X^n]: scipy.stats.invgamma.moment(n, a, loc, scale).
func (InverseGamma) PDF ¶
func (d InverseGamma) PDF(x float64) float64
PDF is the probability density at x: scipy.stats.invgamma.pdf(x, a, loc, scale).
func (InverseGamma) PPF ¶
func (d InverseGamma) PPF(p float64) float64
PPF is the quantile function, the inverse of CDF: scipy.stats.invgamma.ppf(p, a, loc, scale).
func (InverseGamma) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.invgamma.rvs(a, loc, scale, size=size, random_state=g).
func (InverseGamma) SF ¶
func (d InverseGamma) SF(x float64) float64
SF is the survival function P(X > x): scipy.stats.invgamma.sf(x, a, loc, scale).
func (InverseGamma) Skew ¶
func (d InverseGamma) Skew() float64
Skew is the skewness: scipy.stats.invgamma.stats(a, loc, scale, moments="s").
func (InverseGamma) Std ¶
func (d InverseGamma) Std() float64
Std is the standard deviation: scipy.stats.invgamma.std(a, loc, scale).
func (InverseGamma) Support ¶
func (d InverseGamma) Support() (lo, hi float64)
Support is the interval where the density is positive: scipy.stats.invgamma.support(a, loc, scale).
func (InverseGamma) Validate ¶
func (d InverseGamma) Validate() error
Validate returns an error wrapping ErrParam unless Scale is positive and finite, Loc finite and the shape parameters in their domain.
func (InverseGamma) Var ¶
func (d InverseGamma) Var() float64
Var is the variance: scipy.stats.invgamma.var(a, loc, scale).
type KDEBandwidth ¶
type KDEBandwidth struct {
Rule BandwidthRule
Factor float64
Func func(k *GaussianKDE) float64
}
KDEBandwidth selects the bandwidth factor of a GaussianKDE, SciPy's bw_method: Func if it is set (a callable), else Factor if it is positive (a scalar), else Rule. The zero value is Scott's rule.
type KSOptions ¶
type KSOptions struct {
// Alternative: TwoSided compares the distributions for equality; Less
// is the alternative that the CDF of the (first) sample lies below the
// hypothesised (second) one somewhere (statistic D-); Greater that it
// lies above (statistic D+).
Alternative Alternative
// Method selects the p-value: MethodAuto, MethodExact,
// MethodAsymptotic or (one-sample, two-sided only) MethodApprox.
Method Method
}
KSOptions are the options of KSTest1Samp and KSTest2Samp. The zero value (or nil) is SciPy's default: two-sided, method "auto".
type KSResult ¶
type KSResult struct {
Statistic, PValue float64
// StatisticLocation is the observation at which the statistic is
// attained (statistic_location).
StatisticLocation float64
// StatisticSign is +1 when the statistic is the maximum of the
// (first) empirical CDF minus the other CDF, -1 when it is the
// maximum of the opposite difference (statistic_sign); 0 when the
// result is NaN.
StatisticSign int
}
KSResult is the outcome of a Kolmogorov-Smirnov test (SciPy's KstestResult).
func KSTest1Samp ¶
KSTest1Samp is the one-sample Kolmogorov-Smirnov test of the null hypothesis that x is a sample of the continuous distribution whose CDF is cdf (a distribution's CDF method value, e.g. Normal{Scale: 1}.CDF, or any function): scipy.stats.ks_1samp(x, cdf, alternative, method).
The p-value of the two-sided test comes from the exact distribution of D_n (scipy.stats.kstwo) with MethodAuto and MethodExact, from its limit (scipy.stats.kstwobign at D·sqrt(n)) with MethodAsymptotic, and from twice the one-sided p-value with MethodApprox; one-sided tests always use the exact distribution of D+_n (scipy.stats.ksone).
func KSTest2Samp ¶
KSTest2Samp is the two-sample Kolmogorov-Smirnov test of the null hypothesis that a and b are samples of the same continuous distribution: scipy.stats.ks_2samp(a, b, alternative, method).
With MethodAuto the p-value is exact when both samples have at most 10000 observations, asymptotic otherwise. The exact p-values count the lattice paths staying inside (or crossing) the boundary (Hodges 1958; Viehmann 2021), as SciPy does; when the exact computation is not possible (lcm(n1, n2) too large, or overflow) the asymptotic one is used instead, as SciPy does with a warning. The asymptotic two-sided p-value is kstwo's survival function at round(n1·n2/(n1+n2)), the one-sided one Hodges' approximation (his eq. 5.3).
type KendallOptions ¶
type KendallOptions struct {
Variant KendallVariant
Method Method // MethodAuto, MethodExact or MethodAsymptotic
Alternative Alternative
}
KendallOptions are the options of Kendalltau. The zero value (or nil) is SciPy's default: tau-b, method "auto", two-sided.
type KendallVariant ¶
type KendallVariant int
KendallVariant selects Kendall's tau-b or tau-c (SciPy's variant=). The zero value is TauB, SciPy's default.
const ( // TauB is tau-b, adjusted for ties in either variable. TauB KendallVariant = iota // TauC is Stuart's tau-c, for rectangular contingency tables. TauC )
type Laplace ¶
type Laplace struct {
Loc, Scale float64
}
Laplace is the Laplace (double exponential) distribution with median Loc and scale Scale: density exp(-|x|)/2 in standard form: scipy.stats.laplace(loc, scale).
The halving is folded into the double-double exponent (exp(-|x| - ln 2)), so that the density and the tails round once, also where they are subnormal; LogCDF and LogSF use log1p(-exp(-|x|)/2) on the far side, where SciPy's log(1 - exp(-x)/2) loses the low bits.
func FitLaplace ¶
func FitLaplace[D Data](x D, o *FitOptions) (Laplace, error)
FitLaplace returns the maximum-likelihood Laplace distribution for x: Loc the median and Scale the mean absolute deviation from it, or the other one when Loc or Scale is fixed: scipy.stats.laplace.fit(x, floc=, fscale=). The result is SciPy's to the bit.
func NewLaplace ¶
NewLaplace returns Laplace{Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.laplace(loc, scale).
func (Laplace) Entropy ¶
Entropy is the differential entropy in nats: scipy.stats.laplace.entropy(loc, scale).
func (Laplace) Interval ¶
Interval is the equal-tailed interval with the given probability mass: scipy.stats.laplace.interval(confidence, loc, scale).
func (Laplace) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.laplace.stats(loc, scale, moments="k").
func (Laplace) LogPDF ¶
LogPDF is the logarithm of the density at x: scipy.stats.laplace.logpdf(x, loc, scale).
func (Laplace) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.laplace.moment(n, loc, scale).
func (Laplace) PPF ¶
PPF is the quantile function, the inverse of CDF: scipy.stats.laplace.ppf(p, loc, scale).
func (Laplace) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.laplace.rvs(loc, scale, size=size, random_state=g).
func (Laplace) Support ¶
Support is the interval where the density is positive: scipy.stats.laplace.support(loc, scale).
type LeveneCenter ¶
type LeveneCenter int
LeveneCenter is the center of Levene's test (SciPy's center=). The zero value is CenterMedian, SciPy's default (the Brown-Forsythe test).
const ( CenterMedian LeveneCenter = iota // center="median" CenterMean // center="mean": Levene's original test CenterTrimmed // center="trimmed": the trimmed mean )
type LeveneOptions ¶
type LeveneOptions struct {
Center LeveneCenter
// ProportionToCut is the proportion cut from each end for
// CenterTrimmed (SciPy's proportiontocut; 0 selects 0.05).
ProportionToCut float64
}
LeveneOptions are the options of Levene. The zero value (or nil) is SciPy's default: center "median"; ProportionToCut 0 means SciPy's 0.05.
type Limits ¶
type Limits struct {
Lower, Upper float64
// LowerExclusive and UpperExclusive drop the observations equal to the
// limit (SciPy's inclusive=(False, ...)).
LowerExclusive, UpperExclusive bool
}
Limits restricts the trimmed statistics to the observations between Lower and Upper (use an infinity for an open side), SciPy's limits= and inclusive= arguments.
type LinregressResult ¶
type LinregressResult struct {
Slope, Intercept float64
// RValue is Pearson's correlation coefficient.
RValue float64
// PValue is the p-value of the test of zero slope, by the t
// distribution with n - 2 degrees of freedom.
PValue float64
// StdErr is the standard error of the slope, InterceptStdErr that of
// the intercept.
StdErr, InterceptStdErr float64
}
LinregressResult is the outcome of Linregress (SciPy's LinregressResult).
func Linregress ¶
func Linregress[D Data](x, y D, o *CorrelationOptions) (LinregressResult, error)
Linregress is the least-squares regression line of y on x: scipy.stats.linregress(x, y, alternative=...). With fewer than 2 observations or a NaN every field is NaN; a constant x gives NaN slope and intercept, as in SciPy.
type LogNormal ¶
type LogNormal struct {
S, Loc, Scale float64
}
LogNormal is the log-normal distribution: log X is normal with standard deviation S and mean log(Scale): density exp(-log²(x)/(2S²))/(S x √(2π)) in standard form: scipy.stats.lognorm(s, loc, scale).
z = log(x)/S is carried in double-double: the density takes its square exactly into a double-double exponent (SciPy's exp(-(log x/s)²/2) loses about log2(z²) bits), and CDF, SF and their logarithms add the first-order term of the low part of z to special.Ndtr and special.LogNdtr. PPF and ISF refine special.Ndtri by one Newton step in the tails before exp(S·z), whose relative error is S·z times that of z. The moments use expm1(S²), exact where SciPy's exp(S²) - 1 cancels for small S.
func FitLogNormal ¶
func FitLogNormal[D Data](x D, o *FitOptions) (LogNormal, error)
FitLogNormal returns the maximum-likelihood log-normal distribution for x: scipy.stats.lognorm.fit(x, fs=, floc=, fscale=). With Loc fixed, S and Scale have closed forms (the root mean square and the exponential of the mean of log(x - Loc)), reproduced to the bit; with Loc free, Loc solves the likelihood equation ∂/∂Loc = 0 with S and Scale substituted (Cohen and Whitten 1980), found as SciPy finds it (the same brackets) but to full precision, and kept only where its likelihood beats the limit Loc → min(x).
func NewLogNormal ¶
NewLogNormal returns LogNormal{S: s, Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.lognorm(s, loc, scale).
func (LogNormal) Entropy ¶
Entropy is the differential entropy in nats: scipy.stats.lognorm.entropy(s, loc, scale).
func (LogNormal) Interval ¶
Interval is the equal-tailed interval with the given probability mass: scipy.stats.lognorm.interval(confidence, s, loc, scale).
func (LogNormal) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.lognorm.stats(s, loc, scale, moments="k").
func (LogNormal) LogPDF ¶
LogPDF is the logarithm of the density at x: scipy.stats.lognorm.logpdf(x, s, loc, scale).
func (LogNormal) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.lognorm.moment(n, s, loc, scale).
func (LogNormal) PDF ¶
PDF is the probability density at x: scipy.stats.lognorm.pdf(x, s, loc, scale).
func (LogNormal) PPF ¶
PPF is the quantile function, the inverse of CDF: scipy.stats.lognorm.ppf(p, s, loc, scale).
func (LogNormal) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.lognorm.rvs(s, loc, scale, size=size, random_state=g).
func (LogNormal) SF ¶
SF is the survival function P(X > x): scipy.stats.lognorm.sf(x, s, loc, scale).
func (LogNormal) Skew ¶
Skew is the skewness: scipy.stats.lognorm.stats(s, loc, scale, moments="s").
func (LogNormal) Support ¶
Support is the interval where the density is positive: scipy.stats.lognorm.support(s, loc, scale).
type LogUniform ¶
type LogUniform = Reciprocal
LogUniform is the log-uniform distribution, scipy.stats.loguniform: the same distribution as Reciprocal, under the name SciPy also gives it.
type Logistic ¶
type Logistic struct {
Loc, Scale float64
}
Logistic is the logistic distribution with median Loc and scale Scale: density e^(-x)/(1+e^(-x))² in standard form: scipy.stats.logistic(loc, scale).
With e = exp(-|x|) in double-double, the density is e/(1+e)², CDF and SF e/(1+e) and 1/(1+e), their logarithms -log1p(e) and -|x| - log1p(e), each rounded once (also where subnormal). PPF is the logit, through log1p((2p-1)/(1-p)) near p = 1/2 where log p - log(1-p) would cancel.
func FitLogistic ¶
func FitLogistic[D Data](x D, o *FitOptions) (Logistic, error)
FitLogistic returns the maximum-likelihood logistic distribution for x: scipy.stats.logistic.fit(x, floc=, fscale=). Loc and Scale solve the likelihood equations Σ expit((x-Loc)/Scale) = n/2 and Σ c·tanh(c/2) = n, c = (x-Loc)/Scale, as in SciPy, here by nested bracketed searches to full precision (the first equation is monotone in Loc for each Scale; the second changes sign once in Scale along it).
func NewLogistic ¶
NewLogistic returns Logistic{Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.logistic(loc, scale).
func (Logistic) Entropy ¶
Entropy is the differential entropy in nats: scipy.stats.logistic.entropy(loc, scale).
func (Logistic) Interval ¶
Interval is the equal-tailed interval with the given probability mass: scipy.stats.logistic.interval(confidence, loc, scale).
func (Logistic) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.logistic.stats(loc, scale, moments="k").
func (Logistic) LogPDF ¶
LogPDF is the logarithm of the density at x: scipy.stats.logistic.logpdf(x, loc, scale).
func (Logistic) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.logistic.moment(n, loc, scale).
func (Logistic) PPF ¶
PPF is the quantile function, the inverse of CDF: scipy.stats.logistic.ppf(p, loc, scale).
func (Logistic) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.logistic.rvs(loc, scale, size=size, random_state=g).
func (Logistic) Support ¶
Support is the interval where the density is positive: scipy.stats.logistic.support(loc, scale).
type Lomax ¶
type Lomax struct {
C, Loc, Scale float64
}
Lomax is the Lomax (Pareto of the second kind) distribution with shape C: density C/(1+x)^(C+1) on [0, ∞) in standard form: scipy.stats.lomax(c, loc, scale), Pareto(C) shifted by -1.
With t = C log1p(x) in double-double, SF is exp(-t), CDF -expm1(-t), LogCDF log(1 - exp(-t)) without cancellation, PPF expm1(-log1p(-p)/C) and ISF expm1(-log(q)/C), each rounded once. Moments that do not exist are +Inf or NaN as in SciPy.
func FitLomax ¶
func FitLomax[D Data](x D, o *FitOptions) (Lomax, error)
FitLomax returns the maximum-likelihood Lomax distribution for x: scipy.stats.lomax.fit(x, fc=, floc=, fscale=), maximised numerically from SciPy's starting point (C = 1, Loc and Scale by the method of moments moved to cover the data), to a tighter optimum than SciPy's.
func NewLomax ¶
NewLomax returns Lomax{C: c, Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.lomax(c, loc, scale).
func (Lomax) Entropy ¶
Entropy is the differential entropy in nats: scipy.stats.lomax.entropy(c, loc, scale).
func (Lomax) Interval ¶
Interval is the equal-tailed interval with the given probability mass: scipy.stats.lomax.interval(confidence, c, loc, scale).
func (Lomax) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.lomax.stats(c, loc, scale, moments="k").
func (Lomax) LogPDF ¶
LogPDF is the logarithm of the density at x: scipy.stats.lomax.logpdf(x, c, loc, scale).
func (Lomax) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.lomax.moment(n, c, loc, scale).
func (Lomax) PPF ¶
PPF is the quantile function, the inverse of CDF: scipy.stats.lomax.ppf(p, c, loc, scale).
func (Lomax) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.lomax.rvs(c, loc, scale, size=size, random_state=g).
func (Lomax) Support ¶
Support is the interval where the density is positive: scipy.stats.lomax.support(c, loc, scale).
type MADOptions ¶
type MADOptions struct {
// Scale divides the result (0 means 1); MADNormal is scale="normal".
Scale float64
// Center, when not nil, computes the center from the (NaN-free) data;
// by default the median.
Center func([]float64) float64
// OmitNaN ignores the NaNs; by default a NaN gives NaN.
OmitNaN bool
}
MADOptions are the options of MedianAbsDeviation.
type MannWhitneyUOptions ¶
type MannWhitneyUOptions struct {
Alternative Alternative
// Method is MethodAuto (see MannWhitneyU), MethodExact or
// MethodAsymptotic.
Method Method
// NoContinuity disables the continuity correction of the asymptotic
// p-value (SciPy's use_continuity=False).
NoContinuity bool
}
MannWhitneyUOptions are the options of MannWhitneyU. The zero value (or nil) is SciPy's default: two-sided, method "auto", with the continuity correction.
type MeanOptions ¶
type MeanOptions struct {
// Weights, when not nil, weight the observations (numpy.average's
// weights=); they must not sum to zero.
Weights []float64
// Ddof is the delta degrees of freedom of Var and Std (numpy's ddof=,
// default 0): the sum of squares is divided by n - Ddof, or by the sum
// of the weights minus Ddof with Weights (frequency weights,
// numpy.cov(x, fweights=w, ddof=Ddof)).
Ddof float64
// OmitNaN ignores the NaNs (numpy.nanmean, numpy.nanvar, numpy.nanstd);
// by default a NaN gives a NaN result.
OmitNaN bool
}
MeanOptions are the options of Mean, Average, Var and Std.
type MedianOptions ¶
type MedianOptions struct {
// OmitNaN ignores the NaNs (numpy.nanmedian); by default a NaN gives NaN.
OmitNaN bool
}
MedianOptions are the options of Median.
type Method ¶
type Method int
Method selects how a test computes its p-value: SciPy's method= argument of the rank, correlation and Kolmogorov-Smirnov tests. The zero value is MethodAuto, SciPy's default.
const ( // MethodAuto is method="auto": the exact distribution when it is cheap // and valid, the asymptotic one otherwise (each test documents its // rule). MethodAuto Method = iota // MethodExact is method="exact": the exact null distribution. MethodExact // MethodAsymptotic is method="asymptotic" (method="asymp" for the // Kolmogorov-Smirnov tests): the large-sample approximation. MethodAsymptotic // MethodApprox is the Kolmogorov-Smirnov one-sample test's // method="approx": twice the one-sided exact p-value. MethodApprox )
type ModeResult ¶
type ModeResult struct {
// Mode is the smallest of the most frequent values.
Mode float64
// Count is its number of occurrences.
Count int
}
ModeResult is scipy.stats.mode's result.
func Mode ¶
func Mode[D Data](x D, o *NaNOptions) (ModeResult, error)
Mode returns the most frequent value of the data (the smallest of them on a tie) and its count: scipy.stats.mode(x). All NaNs count as one value, ordered after every number.
type MomentOptions ¶
type MomentOptions struct {
// Center, when not nil, is the point about which the moment is taken
// (SciPy's center=); by default the mean.
Center *float64
// OmitNaN ignores the NaNs (nan_policy="omit"); by default a NaN gives
// NaN.
OmitNaN bool
}
MomentOptions are the options of Moment.
type Multinomial ¶
type Multinomial struct {
// contains filtered or unexported fields
}
Multinomial is the multinomial distribution of the counts in K categories of N independent trials with category probabilities P: scipy.stats.multinomial(n, p).
func NewMultinomial ¶
func NewMultinomial(n int, p []float64) (*Multinomial, error)
NewMultinomial returns the multinomial distribution. It returns an error wrapping ErrParam when n < 0, a probability lies outside [0, 1], or the probabilities do not sum to 1 within 10ε (SciPy returns NaN from every method for such parameters).
func (*Multinomial) Cov ¶
func (m *Multinomial) Cov() *ndarray.Array
Cov returns the K×K covariance matrix n(diag(p) - p·pᵀ): scipy.stats.multinomial.cov.
func (*Multinomial) Entropy ¶
func (m *Multinomial) Entropy() float64
Entropy returns the entropy: scipy.stats.multinomial.entropy, which evaluates -log n! - nΣpᵢlog pᵢ + Σᵢ E[log Xᵢ!] with Xᵢ ~ Bin(n, pᵢ). Those terms nearly cancel (SciPy loses about 1e-13 relative at n = 1000); with Stirling's formula for each log m! the large parts cancel exactly, leaving
Σᵢ E[mnBd0(Xᵢ, npᵢ) + (log(2πXᵢ)/2 + δ(Xᵢ))·[Xᵢ > 0]] - log(2πn)/2 - δ(n)
of moderate, mostly positive terms, summed with compensation, and binomial probabilities by Loader's saddle-point algorithm.
func (*Multinomial) LogPMF ¶
func (m *Multinomial) LogPMF(x []float64) (float64, error)
LogPMF returns the log-probability of the counts x (K of them): scipy.stats.multinomial.logpmf. Counts that are negative, fractional or do not sum to N have probability 0 (-Inf); a NaN count gives NaN.
func (*Multinomial) LogPMFPoints ¶
func (m *Multinomial) LogPMFPoints(x *ndarray.Array) ([]float64, error)
LogPMFPoints returns LogPMF at each row of x, an (n, K) array of counts (any dtype; a 1-D x is one point).
func (*Multinomial) Mean ¶
func (m *Multinomial) Mean() []float64
Mean returns n·p: scipy.stats.multinomial.mean.
func (*Multinomial) P ¶
func (m *Multinomial) P() []float64
P returns the category probabilities (a copy).
func (*Multinomial) PMF ¶
func (m *Multinomial) PMF(x []float64) (float64, error)
PMF returns the probability of the counts x: scipy.stats.multinomial.pmf.
type MultivariateNormal ¶
type MultivariateNormal struct {
// contains filtered or unexported fields
}
MultivariateNormal is the multivariate normal distribution with mean vector Mean and covariance matrix Cov: scipy.stats.multivariate_normal( mean, cov, allow_singular).
The covariance is examined as SciPy's _PSD does, with the symmetric eigendecomposition of its lower triangle: an eigenvalue below -1e6·ε·max|λ| makes it invalid, one of magnitude at most 1e6·ε·max|λ| makes it singular. A nonsingular covariance is then factored again by a Cholesky decomposition carried in double-double, and the density solves with that factor (no inverse is formed), so the Mahalanobis distance, the log-determinant and the log-density are accurate to a few ULP even for ill-conditioned covariances, where the float64 eigendecomposition SciPy uses loses cond(Σ)·ε. A singular covariance (AllowSingular) is handled as SciPy does, with the pseudo-inverse from the eigendecomposition.
func NewMultivariateNormal ¶
func NewMultivariateNormal(mean []float64, cov *ndarray.Array, o *MultivariateNormalOptions) (*MultivariateNormal, error)
NewMultivariateNormal returns the multivariate normal distribution with the given mean (nil is the zero vector) and covariance: nil is the identity, a 0-d array s is s·I, a 1-D array the diagonal, a 2-D array the matrix (SciPy's conventions). The dimension is len(mean), or, when mean is nil, the side of cov. It returns an error wrapping ErrParam when cov is not symmetric positive semidefinite, is singular without AllowSingular, or does not match the mean.
func (*MultivariateNormal) CDF ¶
func (m *MultivariateNormal) CDF(x []float64, o *MultivariateNormalCDFOptions) (float64, error)
CDF returns P(Lower < X ≤ x): scipy.stats.multivariate_normal.cdf(x, mean, cov, maxpts, abseps, lower_limit=Lower, rng=RNG).
For d = 1 it is the normal cdf, special.Ndtr((x-μ)/σ) (or the difference of two survival functions above the mean). For d = 2 it is Genz's bivariate normal algorithm (as in SciPy), but applied to the orthant or rectangle reflected towards the lower-left tail, so that a small probability is not the cancelling difference of numbers near 1: SciPy returns 0 for P(X ≤ -10, Y ≤ -10); this returns the probability to a relative accuracy of about 1e-14. For d ≥ 3 it is the Genz–Bretz randomized lattice rule of SciPy's _qmvn with its automatic refinement: with the same generator the lattice, the shifts and the value are SciPy's.
func (*MultivariateNormal) CDFEstimate ¶
func (m *MultivariateNormal) CDFEstimate(x []float64, o *MultivariateNormalCDFOptions) (CDFEstimate, error)
CDFEstimate is CDF with the error estimate and the number of points.
func (*MultivariateNormal) CDFPoints ¶
func (m *MultivariateNormal) CDFPoints(x *ndarray.Array, o *MultivariateNormalCDFOptions) ([]float64, error)
CDFPoints is CDF at each point of x (read as in LogPDFPoints), drawing from one generator point after point as SciPy does.
func (*MultivariateNormal) Cov ¶
func (m *MultivariateNormal) Cov() *ndarray.Array
Cov returns the covariance matrix, d×d (a copy).
func (*MultivariateNormal) Dim ¶
func (m *MultivariateNormal) Dim() int
Dim returns the dimension d.
func (*MultivariateNormal) Entropy ¶
func (m *MultivariateNormal) Entropy() float64
Entropy returns the differential entropy (rank·(1 + log 2π) + log pdet)/2: scipy.stats.multivariate_normal.entropy.
func (*MultivariateNormal) LogCDF ¶
func (m *MultivariateNormal) LogCDF(x []float64, o *MultivariateNormalCDFOptions) (float64, error)
LogCDF returns the logarithm of CDF (NaN where a swapped limit makes the probability negative; SciPy returns a complex number there). For d = 1 with no lower limit it is special.LogNdtr, accurate far in the tail.
func (*MultivariateNormal) LogPDF ¶
func (m *MultivariateNormal) LogPDF(x []float64) (float64, error)
LogPDF returns the log-density at the point x, which must have d coordinates: scipy.stats.multivariate_normal.logpdf.
func (*MultivariateNormal) LogPDFPoints ¶
func (m *MultivariateNormal) LogPDFPoints(x *ndarray.Array) ([]float64, error)
LogPDFPoints returns the log-density at each point of x, read as SciPy reads quantiles: coordinates along the last axis (a 1-D x is n points when d is 1, one point otherwise). The result has one value per point, in row-major order of the leading axes.
func (*MultivariateNormal) LogPDet ¶
func (m *MultivariateNormal) LogPDet() float64
LogPDet returns the logarithm of the pseudo-determinant of the covariance: the sum of the logarithms of its nonnegligible eigenvalues (the log-determinant when it is nonsingular).
func (*MultivariateNormal) Mean ¶
func (m *MultivariateNormal) Mean() []float64
Mean returns the mean vector (a copy).
func (*MultivariateNormal) PDF ¶
func (m *MultivariateNormal) PDF(x []float64) (float64, error)
PDF returns the density at the point x, which must have d coordinates: scipy.stats.multivariate_normal.pdf. It is the exponential of the double-double log-density, so it is accurate to about one ULP.
func (*MultivariateNormal) PDFPoints ¶
func (m *MultivariateNormal) PDFPoints(x *ndarray.Array) ([]float64, error)
PDFPoints is PDF at each point of x, read as in LogPDFPoints.
func (*MultivariateNormal) Rank ¶
func (m *MultivariateNormal) Rank() int
Rank returns the rank of the covariance (d unless it is singular).
func (*MultivariateNormal) Rvs ¶
Rvs draws size points, an array of shape (size, d), as scipy.stats.multivariate_normal.rvs(mean, cov, size, random_state=g) does: NumPy's Generator.multivariate_normal with its SVD factor. The standard normal draws are NumPy's bit for bit; the points are NumPy's exactly for d = 1 and to a few ULP for d ≥ 2 (the two SVDs round differently; very rarely they choose opposite signs for a singular vector, and the points then differ, though they have the same distribution).
type MultivariateNormalCDFOptions ¶
type MultivariateNormalCDFOptions struct {
// Lower is the lower limit of integration (SciPy's lower_limit); nil is
// -∞ in every coordinate. Where a lower limit exceeds the upper one the
// two are swapped and the sign of the result flips, as in SciPy.
Lower []float64
// MaxPts bounds the number of integration points for d ≥ 3; 0 is
// 1000000·d (SciPy's maxpts).
MaxPts int
// AbsEps is the target error for d ≥ 3; 0 is 1e-5 (SciPy's abseps;
// SciPy's releps is not used by its integrator and has no counterpart).
AbsEps float64
// RNG randomizes the lattice rule for d ≥ 3 (SciPy's rng). nil uses a
// fresh random.DefaultRNG(0) for each call, so that results are
// deterministic; pass a generator to reproduce SciPy's value for the
// same seed (it is drawn from point after point, as SciPy does).
RNG *random.Generator
}
MultivariateNormalCDFOptions configures MultivariateNormal.CDF and LogCDF. The zero value is SciPy's default.
type MultivariateNormalFitOptions ¶
type MultivariateNormalFitOptions struct {
// FixMean, when not nil, is the mean (length d) instead of the sample
// mean: SciPy's fix_mean.
FixMean []float64
// FixCov, when not nil, is the covariance (d×d, symmetric positive
// semidefinite) instead of the estimate: SciPy's fix_cov.
FixCov *ndarray.Array
}
MultivariateNormalFitOptions configures FitMultivariateNormal.
type MultivariateNormalOptions ¶
type MultivariateNormalOptions struct {
// AllowSingular accepts a positive semidefinite covariance that is
// singular (SciPy's allow_singular=True): the density is then taken on
// the support, the affine subspace mean + range(cov), with the
// pseudo-determinant.
AllowSingular bool
}
MultivariateNormalOptions configures NewMultivariateNormal. The zero value is SciPy's default.
type NaNOptions ¶
type NaNOptions struct {
// OmitNaN ignores the NaNs (nan_policy="omit"); by default a NaN gives a
// NaN result (for Mode, the NaNs count as one value, as in SciPy).
OmitNaN bool
}
NaNOptions are the options of the statistics whose only option is the NaN policy.
type NegativeBinomial ¶
type NegativeBinomial struct {
N, P, Loc float64
}
NegativeBinomial is the number of failures before the N-th success in trials of success probability P: mass Γ(N+k)/(Γ(N) k!) P^N (1-P)^k on k = 0, 1, ..., for real N > 0 and P in (0, 1]: scipy.stats.nbinom(n, p, loc).
PMF is R's dnbinom: N/(N+k) times the binomial mass of N successes in N+k trials, in Loader's form (see binomTerm) with N+k carried in double-double. CDF and SF are special.BetaInc(N, k+1, P) and its complement.
func NewNegativeBinomial ¶
func NewNegativeBinomial(n float64, p float64, loc float64) (NegativeBinomial, error)
NewNegativeBinomial returns NegativeBinomial{N: n, P: p, Loc: loc}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.nbinom(n, p, loc).
func (NegativeBinomial) CDF ¶
func (d NegativeBinomial) CDF(k float64) float64
CDF is P(X <= k): scipy.stats.nbinom.cdf(k, n, p, loc).
func (NegativeBinomial) Entropy ¶
func (d NegativeBinomial) Entropy() float64
Entropy is the Shannon entropy in nats: scipy.stats.nbinom.entropy(n, p, loc).
func (NegativeBinomial) ISF ¶
func (d NegativeBinomial) ISF(q float64) float64
ISF is the smallest k with SF(k) <= q: scipy.stats.nbinom.isf(q, n, p, loc).
func (NegativeBinomial) Interval ¶
func (d NegativeBinomial) Interval(confidence float64) (lo, hi float64)
Interval is the interval with the given probability mass between PPF((1-c)/2) and PPF((1+c)/2): scipy.stats.nbinom.interval(confidence, n, p, loc).
func (NegativeBinomial) Kurtosis ¶
func (d NegativeBinomial) Kurtosis() float64
Kurtosis is the excess kurtosis: scipy.stats.nbinom.stats(n, p, loc, moments="k").
func (NegativeBinomial) LogCDF ¶
func (d NegativeBinomial) LogCDF(k float64) float64
LogCDF is log P(X <= k): scipy.stats.nbinom.logcdf(k, n, p, loc).
func (NegativeBinomial) LogPMF ¶
func (d NegativeBinomial) LogPMF(k float64) float64
LogPMF is log P(X = k): scipy.stats.nbinom.logpmf(k, n, p, loc).
func (NegativeBinomial) LogSF ¶
func (d NegativeBinomial) LogSF(k float64) float64
LogSF is log P(X > k): scipy.stats.nbinom.logsf(k, n, p, loc).
func (NegativeBinomial) Mean ¶
func (d NegativeBinomial) Mean() float64
Mean is E[X]: scipy.stats.nbinom.mean(n, p, loc).
func (NegativeBinomial) Median ¶
func (d NegativeBinomial) Median() float64
Median is PPF(0.5): scipy.stats.nbinom.median(n, p, loc).
func (NegativeBinomial) Moment ¶
func (d NegativeBinomial) Moment(n int) float64
Moment is the non-central moment E[X^n]: scipy.stats.nbinom.moment(n, n, p, loc).
func (NegativeBinomial) PMF ¶
func (d NegativeBinomial) PMF(k float64) float64
PMF is the probability mass P(X = k), zero unless k - Loc is an integer in the support: scipy.stats.nbinom.pmf(k, n, p, loc).
func (NegativeBinomial) PPF ¶
func (d NegativeBinomial) PPF(p float64) float64
PPF is the smallest k with CDF(k) >= p: scipy.stats.nbinom.ppf(p, n, p, loc).
func (NegativeBinomial) Rvs ¶
Rvs draws random variates of the given shape as an int64 array: scipy.stats.nbinom.rvs(n, p, loc, size=size, random_state=g).
func (NegativeBinomial) SF ¶
func (d NegativeBinomial) SF(k float64) float64
SF is P(X > k): scipy.stats.nbinom.sf(k, n, p, loc).
func (NegativeBinomial) Skew ¶
func (d NegativeBinomial) Skew() float64
Skew is the skewness: scipy.stats.nbinom.stats(n, p, loc, moments="s").
func (NegativeBinomial) Std ¶
func (d NegativeBinomial) Std() float64
Std is the standard deviation: scipy.stats.nbinom.std(n, p, loc).
func (NegativeBinomial) Support ¶
func (d NegativeBinomial) Support() (lo, hi float64)
Support is the smallest and largest value with positive mass: scipy.stats.nbinom.support(n, p, loc).
func (NegativeBinomial) Validate ¶
func (d NegativeBinomial) Validate() error
Validate returns an error wrapping ErrParam unless Loc is finite and the shape parameters are in their domain.
func (NegativeBinomial) Var ¶
func (d NegativeBinomial) Var() float64
Var is the variance: scipy.stats.nbinom.var(n, p, loc).
type NoncentralChiSquared ¶
type NoncentralChiSquared struct {
Df, Nc, Loc, Scale float64
}
NoncentralChiSquared is the noncentral chi-squared distribution with Df degrees of freedom and noncentrality Nc (the sum of Df squared normal variables whose means have squares summing to Nc): scipy.stats.ncx2(df, nc, loc, scale). Nc = 0 is ChiSquared.
Every function is the Poisson mixture Σ_j w_j F_{Df+2j}(x), w_j = e^(-Nc/2) (Nc/2)^j / j!, summed from its largest term outwards until the terms no longer matter: the density with the central chi-squared densities, the cdf and the sf with the incomplete gamma functions P and Q of each term, so that both tails are sums of positive terms (no cancellation). The largest term is evaluated in double-double and the others by the exact ratios between neighbours. PPF and ISF invert the cdf and sf (invertCDF).
func NewNoncentralChiSquared ¶
func NewNoncentralChiSquared(df float64, nc float64, loc, scale float64) (NoncentralChiSquared, error)
NewNoncentralChiSquared returns NoncentralChiSquared{Df: df, Nc: nc, Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.ncx2(df, nc, loc, scale).
func (NoncentralChiSquared) CDF ¶
func (d NoncentralChiSquared) CDF(x float64) float64
CDF is P(X <= x): scipy.stats.ncx2.cdf(x, df, nc, loc, scale).
func (NoncentralChiSquared) Entropy ¶
func (d NoncentralChiSquared) Entropy() float64
Entropy is the differential entropy in nats: scipy.stats.ncx2.entropy(df, nc, loc, scale).
func (NoncentralChiSquared) ISF ¶
func (d NoncentralChiSquared) ISF(q float64) float64
ISF is the inverse of SF: scipy.stats.ncx2.isf(q, df, nc, loc, scale).
func (NoncentralChiSquared) Interval ¶
func (d NoncentralChiSquared) Interval(confidence float64) (lo, hi float64)
Interval is the equal-tailed interval with the given probability mass: scipy.stats.ncx2.interval(confidence, df, nc, loc, scale).
func (NoncentralChiSquared) Kurtosis ¶
func (d NoncentralChiSquared) Kurtosis() float64
Kurtosis is the excess kurtosis: scipy.stats.ncx2.stats(df, nc, loc, scale, moments="k").
func (NoncentralChiSquared) LogCDF ¶
func (d NoncentralChiSquared) LogCDF(x float64) float64
LogCDF is log P(X <= x): scipy.stats.ncx2.logcdf(x, df, nc, loc, scale).
func (NoncentralChiSquared) LogPDF ¶
func (d NoncentralChiSquared) LogPDF(x float64) float64
LogPDF is the logarithm of the density at x: scipy.stats.ncx2.logpdf(x, df, nc, loc, scale).
func (NoncentralChiSquared) LogSF ¶
func (d NoncentralChiSquared) LogSF(x float64) float64
LogSF is log P(X > x): scipy.stats.ncx2.logsf(x, df, nc, loc, scale).
func (NoncentralChiSquared) Mean ¶
func (d NoncentralChiSquared) Mean() float64
Mean is E[X]: scipy.stats.ncx2.mean(df, nc, loc, scale).
func (NoncentralChiSquared) Median ¶
func (d NoncentralChiSquared) Median() float64
Median is the median: scipy.stats.ncx2.median(df, nc, loc, scale).
func (NoncentralChiSquared) Moment ¶
func (d NoncentralChiSquared) Moment(n int) float64
Moment is the non-central moment E[X^n]: scipy.stats.ncx2.moment(n, df, nc, loc, scale).
func (NoncentralChiSquared) PDF ¶
func (d NoncentralChiSquared) PDF(x float64) float64
PDF is the probability density at x: scipy.stats.ncx2.pdf(x, df, nc, loc, scale).
func (NoncentralChiSquared) PPF ¶
func (d NoncentralChiSquared) PPF(p float64) float64
PPF is the quantile function, the inverse of CDF: scipy.stats.ncx2.ppf(p, df, nc, loc, scale).
func (NoncentralChiSquared) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.ncx2.rvs(df, nc, loc, scale, size=size, random_state=g).
func (NoncentralChiSquared) SF ¶
func (d NoncentralChiSquared) SF(x float64) float64
SF is the survival function P(X > x): scipy.stats.ncx2.sf(x, df, nc, loc, scale).
func (NoncentralChiSquared) Skew ¶
func (d NoncentralChiSquared) Skew() float64
Skew is the skewness: scipy.stats.ncx2.stats(df, nc, loc, scale, moments="s").
func (NoncentralChiSquared) Std ¶
func (d NoncentralChiSquared) Std() float64
Std is the standard deviation: scipy.stats.ncx2.std(df, nc, loc, scale).
func (NoncentralChiSquared) Support ¶
func (d NoncentralChiSquared) Support() (lo, hi float64)
Support is the interval where the density is positive: scipy.stats.ncx2.support(df, nc, loc, scale).
func (NoncentralChiSquared) Validate ¶
func (d NoncentralChiSquared) Validate() error
Validate returns an error wrapping ErrParam unless Scale is positive and finite, Loc finite and the shape parameters in their domain.
func (NoncentralChiSquared) Var ¶
func (d NoncentralChiSquared) Var() float64
Var is the variance: scipy.stats.ncx2.var(df, nc, loc, scale).
type Normal ¶
type Normal struct {
Loc, Scale float64
}
Normal is the normal (Gaussian) distribution with mean Loc and standard deviation Scale: scipy.stats.norm(loc, scale).
The density is exp(-z²/2)/√(2π) with z² carried exactly and the exponential in double-double, so it is correctly rounded but for rare cases, out to the underflow at |z| ≈ 38.6 (the textbook formula, which SciPy uses, loses log2(z²) bits there). CDF, SF and their logarithms are special.Ndtr and special.LogNdtr at z and -z; PPF and ISF are special.Ndtri at p and, negated, at q.
func FitNormal ¶
func FitNormal[D Data](x D, o *FitOptions) (Normal, error)
FitNormal returns the maximum-likelihood normal distribution for x: the mean and the root mean squared deviation (ddof 0), or the other one when Loc or Scale is fixed in o.Fixed: scipy.stats.norm.fit(x, floc=, fscale=). The result is SciPy's to the bit (the same pairwise sums).
func NewNormal ¶
NewNormal returns Normal{Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.norm(loc, scale).
func (Normal) Entropy ¶
Entropy is the differential entropy in nats: scipy.stats.norm.entropy(loc, scale).
func (Normal) Interval ¶
Interval is the equal-tailed interval with the given probability mass: scipy.stats.norm.interval(confidence, loc, scale).
func (Normal) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.norm.stats(loc, scale, moments="k").
func (Normal) LogPDF ¶
LogPDF is the logarithm of the density at x: scipy.stats.norm.logpdf(x, loc, scale).
func (Normal) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.norm.moment(n, loc, scale).
func (Normal) PPF ¶
PPF is the quantile function, the inverse of CDF: scipy.stats.norm.ppf(p, loc, scale).
func (Normal) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.norm.rvs(loc, scale, size=size, random_state=g).
func (Normal) Support ¶
Support is the interval where the density is positive: scipy.stats.norm.support(loc, scale).
type Pareto ¶
type Pareto struct {
B, Loc, Scale float64
}
Pareto is the Pareto distribution with shape B: density B/x^(B+1) on [1, ∞) in standard form: scipy.stats.pareto(b, loc, scale).
With t = B log x in double-double, SF is exp(-t) and CDF -expm1(-t), rounded once (SciPy's 1 - x^-b loses everything near x = 1), the quantiles exp(-log1p(-p)/B) and exp(-log(q)/B). Moments that do not exist are +Inf or NaN as in SciPy.
func FitPareto ¶
func FitPareto[D Data](x D, o *FitOptions) (Pareto, error)
FitPareto returns the maximum-likelihood Pareto distribution for x: scipy.stats.pareto.fit(x, fb=, floc=, fscale=). With Loc or Scale fixed the estimates have closed forms (Loc + Scale = min(x) and B = n/Σ log((x-Loc)/Scale)), reproduced to the bit; with both free, Scale solves SciPy's Lagrange condition, bracketed as SciPy brackets it but found to full precision.
func NewPareto ¶
NewPareto returns Pareto{B: b, Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.pareto(b, loc, scale).
func (Pareto) Entropy ¶
Entropy is the differential entropy in nats: scipy.stats.pareto.entropy(b, loc, scale).
func (Pareto) Interval ¶
Interval is the equal-tailed interval with the given probability mass: scipy.stats.pareto.interval(confidence, b, loc, scale).
func (Pareto) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.pareto.stats(b, loc, scale, moments="k").
func (Pareto) LogPDF ¶
LogPDF is the logarithm of the density at x: scipy.stats.pareto.logpdf(x, b, loc, scale).
func (Pareto) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.pareto.moment(n, b, loc, scale).
func (Pareto) PPF ¶
PPF is the quantile function, the inverse of CDF: scipy.stats.pareto.ppf(p, b, loc, scale).
func (Pareto) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.pareto.rvs(b, loc, scale, size=size, random_state=g).
func (Pareto) Support ¶
Support is the interval where the density is positive: scipy.stats.pareto.support(b, loc, scale).
type PearsonResult ¶
type PearsonResult struct {
// Statistic is Pearson's product-moment correlation coefficient r.
Statistic float64
// PValue is the p-value of the test of zero correlation, from the
// exact distribution of r for bivariate normal data.
PValue float64
// contains filtered or unexported fields
}
PearsonResult is the outcome of Pearsonr (SciPy's PearsonRResult).
func Pearsonr ¶
func Pearsonr[D Data](x, y D, o *CorrelationOptions) (PearsonResult, error)
Pearsonr is Pearson's correlation coefficient and the p-value of the test of zero correlation: scipy.stats.pearsonr(x, y, alternative=...). Under the null hypothesis r has the beta distribution on [-1, 1] with both shapes n/2 - 1, whose survival function gives the p-value. The samples must have equal lengths of at least 2. A constant sample or a NaN gives a NaN statistic and p-value, as in SciPy.
func (PearsonResult) ConfidenceInterval ¶
func (r PearsonResult) ConfidenceInterval(level float64) (ConfidenceInterval, error)
ConfidenceInterval returns the confidence interval for the population correlation coefficient at the given level (in [0, 1]), by Fisher's z-transformation, on the side of the test's alternative: PearsonRResult.confidence_interval(confidence_level). For n <= 3 the interval is [-1, 1].
type Poisson ¶
type Poisson struct {
Mu, Loc float64
}
Poisson is the Poisson distribution of mean Mu >= 0: mass Mu^k e^(-Mu) / k! on k = 0, 1, ...: scipy.stats.poisson(mu, loc). Mu = 0 is the distribution concentrated at 0, as in SciPy.
PMF and LogPMF use Loader's form exp(-δ(k) - D(k, Mu)) / sqrt(2πk) (see poissonTerm), accurate for every Mu up to 1e15 and beyond, where SciPy's exp(k log Mu - log Γ(k+1) - Mu) loses about log2(Mu) bits to cancellation. CDF and SF are special.GammaQ and special.GammaP.
func NewPoisson ¶
NewPoisson returns Poisson{Mu: mu, Loc: loc}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.poisson(mu, loc).
func (Poisson) Entropy ¶
Entropy is the Shannon entropy in nats: scipy.stats.poisson.entropy(mu, loc).
func (Poisson) Interval ¶
Interval is the interval with the given probability mass between PPF((1-c)/2) and PPF((1+c)/2): scipy.stats.poisson.interval(confidence, mu, loc).
func (Poisson) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.poisson.stats(mu, loc, moments="k").
func (Poisson) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.poisson.moment(n, mu, loc).
func (Poisson) PMF ¶
PMF is the probability mass P(X = k), zero unless k - Loc is an integer in the support: scipy.stats.poisson.pmf(k, mu, loc).
func (Poisson) Rvs ¶
Rvs draws random variates of the given shape as an int64 array: scipy.stats.poisson.rvs(mu, loc, size=size, random_state=g).
func (Poisson) Support ¶
Support is the smallest and largest value with positive mass: scipy.stats.poisson.support(mu, loc).
type PowerMeanOptions ¶
type PowerMeanOptions struct {
// Weights, when not nil, weight the observations (SciPy's weights=).
Weights []float64
// OmitNaN ignores the NaNs (nan_policy="omit"); by default a NaN gives
// NaN.
OmitNaN bool
}
PowerMeanOptions are the options of GMean, HMean and PMean.
type QuantileMethod ¶
type QuantileMethod int
QuantileMethod is the estimator of a sample quantile, NumPy's method= argument of numpy.quantile and numpy.percentile (the nine of Hyndman and Fan, "Sample quantiles in statistical packages", The American Statistician 50(4), 1996, and four discontinuous ones). The zero value is QuantileLinear, NumPy's default.
const ( // QuantileLinear is method="linear" (H&F 7): virtual index (n-1)p. QuantileLinear QuantileMethod = iota // QuantileInvertedCDF is method="inverted_cdf" (H&F 1). QuantileInvertedCDF // QuantileAveragedInvertedCDF is method="averaged_inverted_cdf" (H&F 2). QuantileAveragedInvertedCDF // QuantileClosestObservation is method="closest_observation" (H&F 3). QuantileClosestObservation // QuantileInterpolatedInvertedCDF is method="interpolated_inverted_cdf" (H&F 4). QuantileInterpolatedInvertedCDF // QuantileHazen is method="hazen" (H&F 5). QuantileHazen // QuantileWeibull is method="weibull" (H&F 6). QuantileWeibull // QuantileMedianUnbiased is method="median_unbiased" (H&F 8). QuantileMedianUnbiased // QuantileNormalUnbiased is method="normal_unbiased" (H&F 9). QuantileNormalUnbiased // QuantileLower is method="lower": the order statistic floor((n-1)p). QuantileLower // QuantileHigher is method="higher": the order statistic ceil((n-1)p). QuantileHigher // QuantileMidpoint is method="midpoint": the mean of lower and higher. QuantileMidpoint // QuantileNearest is method="nearest": the order statistic nearest to // (n-1)p, ties to the even index. QuantileNearest )
func (QuantileMethod) String ¶
func (m QuantileMethod) String() string
String returns NumPy's name for the method.
type QuantileOptions ¶
type QuantileOptions struct {
// Method is the estimator (default QuantileLinear).
Method QuantileMethod
// Weights, when not nil, are non-negative weights of the observations
// (NumPy 2's weights=, supported with QuantileInvertedCDF only).
Weights []float64
// OmitNaN ignores the NaNs of the data (numpy.nanquantile); by default a
// NaN gives a NaN result.
OmitNaN bool
}
QuantileOptions are the options of Quantile and Percentile. The zero value (or nil) is NumPy's default.
type RankMethod ¶
type RankMethod int
RankMethod is how RankData ranks tied values: SciPy's rankdata method= argument. The zero value is RankAverage, SciPy's default.
const ( // RankAverage gives each tied value the average of the ranks the group // spans (method="average"). RankAverage RankMethod = iota // RankMin gives each tied value the lowest rank of its group // (method="min", "competition" ranking). RankMin // RankMax gives each tied value the highest rank of its group // (method="max"). RankMax // RankDense ranks the distinct values 1, 2, 3, ... (method="dense"). RankDense // RankOrdinal gives distinct ranks in order of appearance among ties // (method="ordinal"). RankOrdinal )
type RankTestResult ¶
type RankTestResult struct {
Statistic, PValue float64
// ZStatistic is the standardized statistic of the normal
// approximation when the method requested is MethodAsymptotic
// (SciPy's zstatistic attribute), NaN otherwise.
ZStatistic float64
}
RankTestResult is the outcome of MannWhitneyU and Wilcoxon.
func MannWhitneyU ¶
func MannWhitneyU[D Data](x, y D, o *MannWhitneyUOptions) (RankTestResult, error)
MannWhitneyU is the Mann-Whitney U rank test of the null hypothesis that the distributions underlying two independent samples are equal: scipy.stats.mannwhitneyu(x, y, use_continuity, alternative, method). The statistic is U1, that of x. With MethodAuto the p-value is exact (the null distribution by Löffler's recurrence, no correction for ties) when one of the samples has at most 8 observations and there are no ties, asymptotic (normal, tie-corrected) otherwise.
func Wilcoxon ¶
func Wilcoxon[D Data](x, y D, o *WilcoxonOptions) (RankTestResult, error)
Wilcoxon is the Wilcoxon signed-rank test of the null hypothesis that the differences x - y (or x itself when y is empty) are symmetric about zero: scipy.stats.wilcoxon(x, y, zero_method, correction, alternative, method). The statistic is the smaller of the positive- and negative-rank sums for the two-sided test, the positive-rank sum otherwise. Pass a nil y (or an empty one) for the one-sample test.
type Rayleigh ¶
type Rayleigh struct {
Loc, Scale float64
}
Rayleigh is the Rayleigh distribution: density x exp(-x²/2) on [0, ∞) in standard form: scipy.stats.rayleigh(loc, scale), the chi distribution with 2 degrees of freedom.
x²/2 is exact in double-double: the density, SF exp(-x²/2) and CDF -expm1(-x²/2) round once, LogCDF does not cancel, and the quantiles are the square roots of -2 log1p(-p) and -2 log q in double-double.
func FitRayleigh ¶
func FitRayleigh[D Data](x D, o *FitOptions) (Rayleigh, error)
FitRayleigh returns the maximum-likelihood Rayleigh distribution for x: scipy.stats.rayleigh.fit(x, floc=, fscale=). With Loc fixed, Scale is the root mean square of (x - Loc) over √2 (SciPy's value to the bit); otherwise Loc solves the likelihood equation, bracketed as SciPy brackets it below min(x) and found to full precision.
func NewRayleigh ¶
NewRayleigh returns Rayleigh{Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.rayleigh(loc, scale).
func (Rayleigh) Entropy ¶
Entropy is the differential entropy in nats: scipy.stats.rayleigh.entropy(loc, scale).
func (Rayleigh) Interval ¶
Interval is the equal-tailed interval with the given probability mass: scipy.stats.rayleigh.interval(confidence, loc, scale).
func (Rayleigh) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.rayleigh.stats(loc, scale, moments="k").
func (Rayleigh) LogPDF ¶
LogPDF is the logarithm of the density at x: scipy.stats.rayleigh.logpdf(x, loc, scale).
func (Rayleigh) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.rayleigh.moment(n, loc, scale).
func (Rayleigh) PPF ¶
PPF is the quantile function, the inverse of CDF: scipy.stats.rayleigh.ppf(p, loc, scale).
func (Rayleigh) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.rayleigh.rvs(loc, scale, size=size, random_state=g).
func (Rayleigh) Support ¶
Support is the interval where the density is positive: scipy.stats.rayleigh.support(loc, scale).
type Reciprocal ¶
type Reciprocal struct {
A, B, Loc, Scale float64
}
Reciprocal is the reciprocal (log-uniform) distribution on [A, B], 0 < A < B: density 1/(x log(B/A)), so that log X is uniform on [log A, log B]: scipy.stats.reciprocal(a, b, loc, scale), also known as scipy.stats.loguniform (see LogUniform).
log(B/A) and log(x/A) are carried in double-double, through log1p of the exact difference when the ratio is near 1, so that CDF and SF keep full relative accuracy at both ends of the support (SciPy computes SF as 1 - CDF and loses everything near B). PPF is A·exp(p·log(B/A)) and ISF B·exp(-q·log(B/A)), each rounded once. The moments are formed in double-double from the raw moments (B^n - A^n)/(n log(B/A)).
func FitReciprocal ¶
func FitReciprocal[D Data](x D, o *FitOptions) (Reciprocal, error)
FitReciprocal returns the maximum-likelihood reciprocal distribution for x: scipy.stats.reciprocal.fit(x, fa=, fb=, floc=, fscale=). As in SciPy the family is over-parameterised and Scale is held at 1 unless fixed otherwise in o.Fixed. With Loc fixed the likelihood is maximal for the narrowest support holding the data, A and B the extremes of (x - Loc)/Scale, which SciPy's numerical search only approaches; with Loc free (the likelihood is then unbounded as Loc nears the minimum) it is maximised numerically from SciPy's starting point.
func NewReciprocal ¶
func NewReciprocal(a float64, b float64, loc, scale float64) (Reciprocal, error)
NewReciprocal returns Reciprocal{A: a, B: b, Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.reciprocal(a, b, loc, scale).
func (Reciprocal) CDF ¶
func (d Reciprocal) CDF(x float64) float64
CDF is P(X <= x): scipy.stats.reciprocal.cdf(x, a, b, loc, scale).
func (Reciprocal) Entropy ¶
func (d Reciprocal) Entropy() float64
Entropy is the differential entropy in nats: scipy.stats.reciprocal.entropy(a, b, loc, scale).
func (Reciprocal) ISF ¶
func (d Reciprocal) ISF(q float64) float64
ISF is the inverse of SF: scipy.stats.reciprocal.isf(q, a, b, loc, scale).
func (Reciprocal) Interval ¶
func (d Reciprocal) Interval(confidence float64) (lo, hi float64)
Interval is the equal-tailed interval with the given probability mass: scipy.stats.reciprocal.interval(confidence, a, b, loc, scale).
func (Reciprocal) Kurtosis ¶
func (d Reciprocal) Kurtosis() float64
Kurtosis is the excess kurtosis: scipy.stats.reciprocal.stats(a, b, loc, scale, moments="k").
func (Reciprocal) LogCDF ¶
func (d Reciprocal) LogCDF(x float64) float64
LogCDF is log P(X <= x): scipy.stats.reciprocal.logcdf(x, a, b, loc, scale).
func (Reciprocal) LogPDF ¶
func (d Reciprocal) LogPDF(x float64) float64
LogPDF is the logarithm of the density at x: scipy.stats.reciprocal.logpdf(x, a, b, loc, scale).
func (Reciprocal) LogSF ¶
func (d Reciprocal) LogSF(x float64) float64
LogSF is log P(X > x): scipy.stats.reciprocal.logsf(x, a, b, loc, scale).
func (Reciprocal) Mean ¶
func (d Reciprocal) Mean() float64
Mean is E[X]: scipy.stats.reciprocal.mean(a, b, loc, scale).
func (Reciprocal) Median ¶
func (d Reciprocal) Median() float64
Median is the median: scipy.stats.reciprocal.median(a, b, loc, scale).
func (Reciprocal) Moment ¶
func (d Reciprocal) Moment(n int) float64
Moment is the non-central moment E[X^n]: scipy.stats.reciprocal.moment(n, a, b, loc, scale).
func (Reciprocal) PDF ¶
func (d Reciprocal) PDF(x float64) float64
PDF is the probability density at x: scipy.stats.reciprocal.pdf(x, a, b, loc, scale).
func (Reciprocal) PPF ¶
func (d Reciprocal) PPF(p float64) float64
PPF is the quantile function, the inverse of CDF: scipy.stats.reciprocal.ppf(p, a, b, loc, scale).
func (Reciprocal) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.reciprocal.rvs(a, b, loc, scale, size=size, random_state=g).
func (Reciprocal) SF ¶
func (d Reciprocal) SF(x float64) float64
SF is the survival function P(X > x): scipy.stats.reciprocal.sf(x, a, b, loc, scale).
func (Reciprocal) Skew ¶
func (d Reciprocal) Skew() float64
Skew is the skewness: scipy.stats.reciprocal.stats(a, b, loc, scale, moments="s").
func (Reciprocal) Std ¶
func (d Reciprocal) Std() float64
Std is the standard deviation: scipy.stats.reciprocal.std(a, b, loc, scale).
func (Reciprocal) Support ¶
func (d Reciprocal) Support() (lo, hi float64)
Support is the interval where the density is positive: scipy.stats.reciprocal.support(a, b, loc, scale).
func (Reciprocal) Validate ¶
func (d Reciprocal) Validate() error
Validate returns an error wrapping ErrParam unless Scale is positive and finite, Loc finite and the shape parameters in their domain.
func (Reciprocal) Var ¶
func (d Reciprocal) Var() float64
Var is the variance: scipy.stats.reciprocal.var(a, b, loc, scale).
type ShapeOptions ¶
type ShapeOptions struct {
// Unbiased corrects the statistics for bias (SciPy's bias=False); by
// default they are the biased moment ratios, SciPy's default.
Unbiased bool
// Pearson returns Pearson's kurtosis (3 for a normal sample, SciPy's
// fisher=False) rather than Fisher's excess kurtosis.
Pearson bool
// Ddof is Describe's delta degrees of freedom of the variance; nil
// means 1, SciPy's default.
Ddof *float64
// OmitNaN ignores the NaNs (nan_policy="omit"); by default a NaN gives
// NaN.
OmitNaN bool
}
ShapeOptions are the options of Skew, Kurtosis and Describe.
type SkewTestOptions ¶
type SkewTestOptions struct {
Alternative Alternative
}
SkewTestOptions are the options of SkewTest and KurtosisTest. The zero value (or nil) is a two-sided test.
type StudentT ¶
type StudentT struct {
Df, Loc, Scale float64
}
StudentT is Student's t distribution with Df degrees of freedom (Df may be +Inf, the normal distribution): scipy.stats.t(df, loc, scale).
The distribution functions go through the incomplete beta function as in Boost (I_z(1/2, ν/2) or I_z(ν/2, 1/2), whichever argument is not close to 1), the quantile through its inverse with both z and 1-z obtained without cancellation. The density is c(ν)·(1+t²/ν)^(-(ν+1)/2) with the power in double-double and c(ν) from the gamma ratio (an asymptotic series for ν >= 100).
func FitStudentT ¶
func FitStudentT[D Data](x D, o *FitOptions) (StudentT, error)
FitStudentT returns the maximum-likelihood t distribution for x: scipy.stats.t.fit(x, fdf=, floc=, fscale=), numerically from SciPy's starting point (Df = 1).
func NewStudentT ¶
NewStudentT returns StudentT{Df: df, Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.t(df, loc, scale).
func (StudentT) Entropy ¶
Entropy is the differential entropy in nats: scipy.stats.t.entropy(df, loc, scale).
func (StudentT) Interval ¶
Interval is the equal-tailed interval with the given probability mass: scipy.stats.t.interval(confidence, df, loc, scale).
func (StudentT) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.t.stats(df, loc, scale, moments="k").
func (StudentT) LogPDF ¶
LogPDF is the logarithm of the density at x: scipy.stats.t.logpdf(x, df, loc, scale).
func (StudentT) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.t.moment(n, df, loc, scale).
func (StudentT) PPF ¶
PPF is the quantile function, the inverse of CDF: scipy.stats.t.ppf(p, df, loc, scale).
func (StudentT) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.t.rvs(df, loc, scale, size=size, random_state=g).
func (StudentT) Support ¶
Support is the interval where the density is positive: scipy.stats.t.support(df, loc, scale).
type TTestIndOptions ¶
type TTestIndOptions struct {
// Welch selects Welch's test, which does not assume equal variances
// (SciPy's equal_var=False).
Welch bool
// Trim is the proportion in [0, 0.5) cut from each end of each sample
// for Yuen's trimmed t-test (SciPy's trim=).
Trim float64
Alternative Alternative
}
TTestIndOptions are the options of TTestInd. The zero value (or nil) is SciPy's default: Student's test with pooled variance, two-sided, no trimming.
type TTestOptions ¶
type TTestOptions struct {
Alternative Alternative
}
TTestOptions are the options of TTest1Samp and TTestRel. The zero value (or nil) is SciPy's default: a two-sided test.
type TTestResult ¶
type TTestResult struct {
// Statistic is the t statistic.
Statistic float64
// PValue is the p-value for the alternative hypothesis.
PValue float64
// DF is the number of degrees of freedom of the t distribution.
DF float64
// contains filtered or unexported fields
}
TTestResult is the outcome of a t-test (SciPy's TtestResult).
func TTest1Samp ¶
func TTest1Samp[D Data](x D, popmean float64, o *TTestOptions) (TTestResult, error)
TTest1Samp is the one-sample t-test of the null hypothesis that the mean of the population x is drawn from is popmean: scipy.stats.ttest_1samp(x, popmean, alternative=...).
func TTestInd ¶
func TTestInd[D Data](a, b D, o *TTestIndOptions) (TTestResult, error)
TTestInd is the two-sample t-test of the null hypothesis that two independent samples have identical means: scipy.stats.ttest_ind(a, b, equal_var=!Welch, trim=Trim, alternative=...). With Trim > 0 it is Yuen's test on the trimmed means and winsorized variances.
func TTestRel ¶
func TTestRel[D Data](a, b D, o *TTestOptions) (TTestResult, error)
TTestRel is the paired t-test of the null hypothesis that the mean of the differences a - b is zero: scipy.stats.ttest_rel(a, b, alternative=...). a and b must have the same length.
func (TTestResult) ConfidenceInterval ¶
func (r TTestResult) ConfidenceInterval(level float64) (ConfidenceInterval, error)
ConfidenceInterval returns the confidence interval at the given level (in [0, 1]) for the population mean (one-sample test), the difference of the population means (two-sample tests) or the mean difference (paired test), on the side of the test's alternative (one-sided intervals have an infinite bound): TtestResult.confidence_interval(confidence_level).
type TestResult ¶
type TestResult struct {
Statistic, PValue float64
}
TestResult is the outcome of a test that has a statistic and a p-value only (SciPy's two-field result tuples and SignificanceResult).
func Bartlett ¶
func Bartlett[D Data](samples ...D) (TestResult, error)
Bartlett is Bartlett's test of the null hypothesis that the groups have equal variances: scipy.stats.bartlett(*samples). At least two groups are required; an empty group or a NaN gives NaN.
func ChiSquare ¶
func ChiSquare[D Data](observed D, o *ChiSquareOptions) (TestResult, error)
ChiSquare is Pearson's chi-squared goodness-of-fit test of the observed frequencies against the expected ones: scipy.stats.chisquare(f_obs, f_exp, ddof).
func FOneway ¶
func FOneway[D Data](o *FOnewayOptions, samples ...D) (TestResult, error)
FOneway is the one-way analysis of variance of the null hypothesis that the groups have the same population mean: scipy.stats.f_oneway(*samples, equal_var=!Welch). At least two groups are required. An empty group, a NaN, or groups of one observation each give NaN; when every group is constant the statistic is +Inf (NaN if all the values are equal), as in SciPy.
func FisherExact ¶
func FisherExact(table [2][2]int64, o *FisherExactOptions) (TestResult, error)
FisherExact is Fisher's exact test of independence for a 2×2 table of counts: scipy.stats.fisher_exact(table, alternative). The statistic is the sample odds ratio table[0][0]·table[1][1] / (table[0][1]·table[1][0]) (+Inf when the denominator is zero, NaN with a p-value of 1 when a row or a column sums to zero); the p-value is computed from the hypergeometric distribution of table[0][0] given the margins, the two-sided one summing the probabilities of the tables no more likely than the observed one (relative tolerance 1e-14), as SciPy does.
func JarqueBera ¶
func JarqueBera[D Data](x D) (TestResult, error)
JarqueBera is the Jarque-Bera goodness-of-fit test of normality, n/6·(S² + (K-3)²/4) against the chi-squared distribution with 2 degrees of freedom: scipy.stats.jarque_bera(x). Constant data or a NaN give NaN; an empty sample gives NaN, as in SciPy.
func Kendalltau ¶
func Kendalltau[D Data](x, y D, o *KendallOptions) (TestResult, error)
Kendalltau is Kendall's rank correlation tau and the p-value of the test of independence: scipy.stats.kendalltau(x, y, method, variant, alternative). The p-value depends only on the difference of concordant and discordant pairs: with MethodAuto it is the exact one (Kendall's recursion) when there are no ties and n <= 33 or the discordant (or concordant) pairs number at most 1, the normal approximation with tie corrections otherwise. MethodExact with ties is an error, as in SciPy. With fewer than 2 observations, a constant sample or a NaN the result is NaN.
func KruskalWallis ¶
func KruskalWallis[D Data](samples ...D) (TestResult, error)
KruskalWallis is the Kruskal-Wallis H test of the null hypothesis that the medians of all groups are equal: scipy.stats.kruskal(*samples). The statistic is corrected for ties; the p-value is from the chi-squared distribution with k - 1 degrees of freedom. At least two groups are required; an empty group or a NaN gives a NaN result, as in SciPy.
func KurtosisTest ¶
func KurtosisTest[D Data](x D, o *SkewTestOptions) (TestResult, error)
KurtosisTest is Anscombe and Glynn's test of the null hypothesis that the kurtosis of the population is that of a normal distribution: scipy.stats.kurtosistest(a, alternative). It needs at least 5 observations (fewer, constant data or a NaN give NaN, as in SciPy).
func Levene ¶
func Levene[D Data](o *LeveneOptions, samples ...D) (TestResult, error)
Levene is Levene's test of the null hypothesis that the groups have equal variances: scipy.stats.levene(*samples, center, proportiontocut). At least two groups are required; an empty group or a NaN gives NaN.
func Normaltest ¶
func Normaltest[D Data](x D) (TestResult, error)
Normaltest is D'Agostino and Pearson's omnibus test of normality, the sum of the squared statistics of SkewTest and KurtosisTest against the chi-squared distribution with 2 degrees of freedom: scipy.stats.normaltest(a). It needs at least 8 observations.
func PowerDivergence ¶
func PowerDivergence[D Data](observed D, lambda float64, o *ChiSquareOptions) (TestResult, error)
PowerDivergence is the Cressie-Read power divergence goodness-of-fit test with power lambda (one of the Lambda constants, or any real): scipy.stats.power_divergence(f_obs, f_exp, ddof, lambda_=lambda).
func ShapiroWilk ¶
func ShapiroWilk[D Data](x D) (TestResult, error)
ShapiroWilk is the Shapiro-Wilk test of the null hypothesis that the data come from a normal distribution: scipy.stats.shapiro(x), with SciPy 1.18's algorithm (Royston 1992: the approximate coefficients and the normalising transformation of W; for n = 3 the exact distribution). The data are read whole (an array in row-major order). With fewer than 3 observations, constant data or a NaN, the result is NaN.
func SkewTest ¶
func SkewTest[D Data](x D, o *SkewTestOptions) (TestResult, error)
SkewTest is D'Agostino's test of the null hypothesis that the skewness of the population is that of a normal distribution: scipy.stats.skewtest(a, alternative). It needs at least 8 observations (fewer, constant data or a NaN give NaN, as in SciPy).
func Spearmanr ¶
func Spearmanr[D Data](x, y D, o *CorrelationOptions) (TestResult, error)
Spearmanr is Spearman's rank correlation coefficient of two samples and the p-value of the test of zero correlation by the t distribution with n - 2 degrees of freedom: scipy.stats.spearmanr(x, y, alternative=...). Ties get average ranks. With fewer than 2 observations, a constant sample or a NaN the result is NaN, as in SciPy.
type Triangular ¶
type Triangular struct {
C, Loc, Scale float64
}
Triangular is the triangular distribution on [0, 1] with mode C, 0 <= C <= 1, in standard form: scipy.stats.triang(c, loc, scale), the distribution on [Loc, Loc+Scale] with mode Loc + C·Scale.
The two branches of every function are formed in double-double from the exact differences 1 - x and 1 - C: CDF x²/C below the mode and 1 - (1-x)²/(1-C) above, SF the complements, so that each tail keeps full relative accuracy (SciPy's (x² - 2x + c)/(c - 1) cancels near x = 1); PPF √(C p) and 1 - √((1-C)(1-p)).
func FitTriangular ¶
func FitTriangular[D Data](x D, o *FitOptions) (Triangular, error)
FitTriangular returns the maximum-likelihood triangular distribution for x: scipy.stats.triang.fit(x, fc=, floc=, fscale=), maximised numerically from SciPy's starting point (C = 1, Loc and Scale by the method of moments moved to cover the data), to a tighter optimum than SciPy's.
func NewTriangular ¶
func NewTriangular(c float64, loc, scale float64) (Triangular, error)
NewTriangular returns Triangular{C: c, Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.triang(c, loc, scale).
func (Triangular) CDF ¶
func (d Triangular) CDF(x float64) float64
CDF is P(X <= x): scipy.stats.triang.cdf(x, c, loc, scale).
func (Triangular) Entropy ¶
func (d Triangular) Entropy() float64
Entropy is the differential entropy in nats: scipy.stats.triang.entropy(c, loc, scale).
func (Triangular) ISF ¶
func (d Triangular) ISF(q float64) float64
ISF is the inverse of SF: scipy.stats.triang.isf(q, c, loc, scale).
func (Triangular) Interval ¶
func (d Triangular) Interval(confidence float64) (lo, hi float64)
Interval is the equal-tailed interval with the given probability mass: scipy.stats.triang.interval(confidence, c, loc, scale).
func (Triangular) Kurtosis ¶
func (d Triangular) Kurtosis() float64
Kurtosis is the excess kurtosis: scipy.stats.triang.stats(c, loc, scale, moments="k").
func (Triangular) LogCDF ¶
func (d Triangular) LogCDF(x float64) float64
LogCDF is log P(X <= x): scipy.stats.triang.logcdf(x, c, loc, scale).
func (Triangular) LogPDF ¶
func (d Triangular) LogPDF(x float64) float64
LogPDF is the logarithm of the density at x: scipy.stats.triang.logpdf(x, c, loc, scale).
func (Triangular) LogSF ¶
func (d Triangular) LogSF(x float64) float64
LogSF is log P(X > x): scipy.stats.triang.logsf(x, c, loc, scale).
func (Triangular) Mean ¶
func (d Triangular) Mean() float64
Mean is E[X]: scipy.stats.triang.mean(c, loc, scale).
func (Triangular) Median ¶
func (d Triangular) Median() float64
Median is the median: scipy.stats.triang.median(c, loc, scale).
func (Triangular) Moment ¶
func (d Triangular) Moment(n int) float64
Moment is the non-central moment E[X^n]: scipy.stats.triang.moment(n, c, loc, scale).
func (Triangular) PDF ¶
func (d Triangular) PDF(x float64) float64
PDF is the probability density at x: scipy.stats.triang.pdf(x, c, loc, scale).
func (Triangular) PPF ¶
func (d Triangular) PPF(p float64) float64
PPF is the quantile function, the inverse of CDF: scipy.stats.triang.ppf(p, c, loc, scale).
func (Triangular) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.triang.rvs(c, loc, scale, size=size, random_state=g).
func (Triangular) SF ¶
func (d Triangular) SF(x float64) float64
SF is the survival function P(X > x): scipy.stats.triang.sf(x, c, loc, scale).
func (Triangular) Skew ¶
func (d Triangular) Skew() float64
Skew is the skewness: scipy.stats.triang.stats(c, loc, scale, moments="s").
func (Triangular) Std ¶
func (d Triangular) Std() float64
Std is the standard deviation: scipy.stats.triang.std(c, loc, scale).
func (Triangular) Support ¶
func (d Triangular) Support() (lo, hi float64)
Support is the interval where the density is positive: scipy.stats.triang.support(c, loc, scale).
func (Triangular) Validate ¶
func (d Triangular) Validate() error
Validate returns an error wrapping ErrParam unless Scale is positive and finite, Loc finite and the shape parameters in their domain.
func (Triangular) Var ¶
func (d Triangular) Var() float64
Var is the variance: scipy.stats.triang.var(c, loc, scale).
type TrimmedOptions ¶
type TrimmedOptions struct {
// Limits, when not nil, restrict the data; nil keeps all of them.
Limits *Limits
// Ddof is the delta degrees of freedom of TVar, TStd and TSem; nil
// means 1, SciPy's default.
Ddof *float64
// OmitNaN ignores the NaNs; by default a NaN gives NaN.
OmitNaN bool
}
TrimmedOptions are the options of TMean, TVar, TStd and TSem.
type Uniform ¶
type Uniform struct {
Loc, Scale float64
}
Uniform is the continuous uniform distribution on [Loc, Loc+Scale]: scipy.stats.uniform(loc, scale).
LogCDF is the correctly rounded log x and LogSF log1p(-x) in double-double (SciPy's log(1-x) loses the low bits of x below 1/2).
func FitUniform ¶
func FitUniform[D Data](x D, o *FitOptions) (Uniform, error)
FitUniform returns the maximum-likelihood uniform distribution for x: scipy.stats.uniform.fit(x, floc=, fscale=), to the bit. Loc is the minimum and Scale the range; with Loc fixed, Scale reaches the maximum; with Scale fixed (at least the range), the support is centred over the data, SciPy's choice among the equally likely ones.
func NewUniform ¶
NewUniform returns Uniform{Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.uniform(loc, scale).
func (Uniform) Entropy ¶
Entropy is the differential entropy in nats: scipy.stats.uniform.entropy(loc, scale).
func (Uniform) Interval ¶
Interval is the equal-tailed interval with the given probability mass: scipy.stats.uniform.interval(confidence, loc, scale).
func (Uniform) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.uniform.stats(loc, scale, moments="k").
func (Uniform) LogPDF ¶
LogPDF is the logarithm of the density at x: scipy.stats.uniform.logpdf(x, loc, scale).
func (Uniform) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.uniform.moment(n, loc, scale).
func (Uniform) PPF ¶
PPF is the quantile function, the inverse of CDF: scipy.stats.uniform.ppf(p, loc, scale).
func (Uniform) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.uniform.rvs(loc, scale, size=size, random_state=g).
func (Uniform) Support ¶
Support is the interval where the density is positive: scipy.stats.uniform.support(loc, scale).
type VonMises ¶
type VonMises struct {
Kappa, Loc, Scale float64
}
VonMises is the von Mises (circular normal) distribution with concentration Kappa >= 0 and mean direction Loc: density exp(Kappa cos x)/(2π I0(Kappa)) in standard form: scipy.stats.vonmises(kappa, loc, scale).
As SciPy's vonmises, it is a circular distribution laid on the real line: the density is 2π-periodic, the support is the whole line, and CDF counts the turns, CDF(x + 2π) = CDF(x) + 1, so that it lies in [0, 1] only on [Loc - π, Loc + π]; PPF and ISF return points of that interval, and the moments, as SciPy's, are those of the interval. Draws are wrapped onto [-π, π] after Loc and Scale are applied, as SciPy wraps them. (SciPy's vonmises_line, the same density restricted to [-π, π], is not provided.)
The density carries cos(x) - 1 = -2 sin²(x/2) in double-double. SciPy computes the CDF by a series truncated for 12 significant digits (and a normal approximation from Kappa = 50); here the tail probability P(X <= x) for x in [-π, 0] is the density at x times ∫_0^{x+π} exp(-Δ(τ)) dτ, Δ(τ) = 2 Kappa sin(τ/2) sin(τ/2 - x) >= 0 the exact difference of the exponents, by tanh-sinh quadrature: full relative accuracy out to the far tail, at the cost of about 250 exponentials per evaluation. PPF solves the CDF by Newton's method on its logarithm.
func FitVonMises ¶
func FitVonMises[D Data](x D, o *FitOptions) (VonMises, error)
FitVonMises returns the maximum-likelihood von Mises distribution for x, read as angles: scipy.stats.vonmises.fit(x, fkappa=, floc=). Loc is the circular mean and Kappa solves I1(Kappa)/I0(Kappa) = mean cos(x - Loc) (zero if that is not positive), bracketed as SciPy brackets it but found to full precision; Loc is returned in [-π, π) and Scale is 1 (as SciPy, which ignores a fixed scale; fixing Scale to anything but 1 is an error here).
func NewVonMises ¶
NewVonMises returns VonMises{Kappa: kappa, Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.vonmises(kappa, loc, scale).
func (VonMises) Entropy ¶
Entropy is the differential entropy in nats: scipy.stats.vonmises.entropy(kappa, loc, scale).
func (VonMises) Interval ¶
Interval is the equal-tailed interval with the given probability mass: scipy.stats.vonmises.interval(confidence, kappa, loc, scale).
func (VonMises) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.vonmises.stats(kappa, loc, scale, moments="k").
func (VonMises) LogCDF ¶
LogCDF is log P(X <= x): scipy.stats.vonmises.logcdf(x, kappa, loc, scale).
func (VonMises) LogPDF ¶
LogPDF is the logarithm of the density at x: scipy.stats.vonmises.logpdf(x, kappa, loc, scale).
func (VonMises) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.vonmises.moment(n, kappa, loc, scale).
func (VonMises) PDF ¶
PDF is the probability density at x: scipy.stats.vonmises.pdf(x, kappa, loc, scale).
func (VonMises) PPF ¶
PPF is the quantile function, the inverse of CDF: scipy.stats.vonmises.ppf(p, kappa, loc, scale).
func (VonMises) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.vonmises.rvs(kappa, loc, scale, size=size, random_state=g): numpy's von Mises draws, moved by Loc and Scale, then wrapped onto [-π, π) as SciPy wraps them (np.mod(x + π, 2π) - π).
func (VonMises) SF ¶
SF is the survival function P(X > x): scipy.stats.vonmises.sf(x, kappa, loc, scale).
func (VonMises) Skew ¶
Skew is the skewness: scipy.stats.vonmises.stats(kappa, loc, scale, moments="s").
func (VonMises) Support ¶
Support is the interval where the density is positive: scipy.stats.vonmises.support(kappa, loc, scale).
type Weibull ¶
type Weibull struct {
C, Loc, Scale float64
}
Weibull is the Weibull (minimum) distribution with shape C: density C x^(C-1) exp(-x^C) on [0, ∞) in standard form: scipy.stats.weibull_min(c, loc, scale).
x^C is carried in double-double as exp(C log x): SF is exp(-x^C) and CDF -expm1(-x^C) rounded once (SciPy's exp(-pow(x, c)) has the relative error of pow times x^c, up to hundreds of ulps in the tail), LogCDF log(1 - exp(-x^C)) without cancellation, and the quantiles exp(log(-log1p(-p))/C) and exp(log(-log q)/C). The variance, skewness and kurtosis come from the differences log Γ(1+k/C) - k log Γ(1+1/C), summed as a series for large C where SciPy's differences of gamma functions cancel.
func FitWeibull ¶
func FitWeibull[D Data](x D, o *FitOptions) (Weibull, error)
FitWeibull returns the maximum-likelihood Weibull distribution for x: scipy.stats.weibull_min.fit(x, fc=, floc=, fscale=). It starts where SciPy starts (C matching the sample skewness, Scale and Loc the variance and mean, or SciPy's generic start when the skewness is below what any C reaches) and maximises the likelihood numerically to a tighter optimum than SciPy's.
func NewWeibull ¶
NewWeibull returns Weibull{C: c, Loc: loc, Scale: scale}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.weibull_min(c, loc, scale).
func (Weibull) Entropy ¶
Entropy is the differential entropy in nats: scipy.stats.weibull_min.entropy(c, loc, scale).
func (Weibull) Interval ¶
Interval is the equal-tailed interval with the given probability mass: scipy.stats.weibull_min.interval(confidence, c, loc, scale).
func (Weibull) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.weibull_min.stats(c, loc, scale, moments="k").
func (Weibull) LogPDF ¶
LogPDF is the logarithm of the density at x: scipy.stats.weibull_min.logpdf(x, c, loc, scale).
func (Weibull) Moment ¶
Moment is the non-central moment E[X^n]: scipy.stats.weibull_min.moment(n, c, loc, scale).
func (Weibull) PDF ¶
PDF is the probability density at x: scipy.stats.weibull_min.pdf(x, c, loc, scale).
func (Weibull) PPF ¶
PPF is the quantile function, the inverse of CDF: scipy.stats.weibull_min.ppf(p, c, loc, scale).
func (Weibull) Rvs ¶
Rvs draws random variates of the given shape: scipy.stats.weibull_min.rvs(c, loc, scale, size=size, random_state=g).
func (Weibull) SF ¶
SF is the survival function P(X > x): scipy.stats.weibull_min.sf(x, c, loc, scale).
func (Weibull) Skew ¶
Skew is the skewness: scipy.stats.weibull_min.stats(c, loc, scale, moments="s").
func (Weibull) Support ¶
Support is the interval where the density is positive: scipy.stats.weibull_min.support(c, loc, scale).
type WilcoxonOptions ¶
type WilcoxonOptions struct {
ZeroMethod ZeroMethod
// Correction applies the continuity correction to the normal
// approximation (SciPy's correction=True).
Correction bool
Alternative Alternative
// Method: MethodAuto, MethodExact or MethodAsymptotic. MethodAuto
// follows SciPy 1.18: the exact distribution when there are at most
// 50 differences and neither ties nor zeros; with ties or zeros and
// at most 13 differences, the exact permutation distribution over all
// 2^n sign changes (SciPy's PermutationMethod); the normal
// approximation otherwise.
Method Method
}
WilcoxonOptions are the options of Wilcoxon. The zero value (or nil) is SciPy's default: zero_method "wilcox", no continuity correction, two-sided, method "auto".
type ZeroMethod ¶
type ZeroMethod int
ZeroMethod is how Wilcoxon treats zero differences (SciPy's zero_method=). The zero value is ZeroWilcox, SciPy's default.
const ( // ZeroWilcox drops the zero differences (zero_method="wilcox"). ZeroWilcox ZeroMethod = iota // ZeroPratt ranks the zeros, then drops them from the statistic // (zero_method="pratt"). ZeroPratt // ZeroZsplit ranks the zeros and splits their ranks evenly between // the positive and negative sums (zero_method="zsplit"). ZeroZsplit )
type Zipf ¶
type Zipf struct {
A, Loc float64
}
Zipf is the zeta distribution: mass k^-A / ζ(A) on k = 1, 2, ..., for A > 1: scipy.stats.zipf(a, loc).
SF is ζ(A, k+1)/ζ(A), the tail summed term by term while the terms matter and by Euler-Maclaurin beyond (zetaTail; special.HurwitzZeta would do, but allocates for small k), and ζ(A) = 1 + ζ(A, 2) by the same sum, so that log ζ(A) is log1p of it for large A. CDF is 1 - SF where SF is below 1/2 and otherwise the partial sum Σ_{j<=k} j^-A / ζ(A), by Euler-Maclaurin summation beyond j = 20 (the difference ζ(A) - ζ(A, k+1) would cancel: SciPy sums the masses one by one). Entropy is log ζ(A) - A ζ'(A)/ζ(A), with -ζ'(A) = Σ log j / j^A by the same summation (SciPy sums at most 1000 masses, which for small A misses much of the tail). The raw moments are SciPy's ζ(A-n)/ζ(A) where A > n+1, +Inf otherwise; the variance, skewness and kurtosis are +Inf or NaN where SciPy's generic rv_discrete.stats makes them so, and otherwise come from the moments of X-1, Σ_(k>=2) (k-1)^r k^-A / ζ(A), formed from the differences ζ(A-j, 2) - ζ(A, 2) without the cancellation of SciPy's raw-moment differences (which loses six digits at A = 20).
func NewZipf ¶
NewZipf returns Zipf{A: a, Loc: loc}, with an error wrapping ErrParam when a parameter is out of the domain: scipy.stats.zipf(a, loc).
func (Zipf) Interval ¶
Interval is the interval with the given probability mass between PPF((1-c)/2) and PPF((1+c)/2): scipy.stats.zipf.interval(confidence, a, loc).
func (Zipf) Kurtosis ¶
Kurtosis is the excess kurtosis: scipy.stats.zipf.stats(a, loc, moments="k").
func (Zipf) PMF ¶
PMF is the probability mass P(X = k), zero unless k - Loc is an integer in the support: scipy.stats.zipf.pmf(k, a, loc).
func (Zipf) Rvs ¶
Rvs draws random variates of the given shape as an int64 array: scipy.stats.zipf.rvs(a, loc, size=size, random_state=g).
func (Zipf) Support ¶
Support is the smallest and largest value with positive mass: scipy.stats.zipf.support(a, loc).
Source Files
¶
- accurate.go
- alternative.go
- anova.go
- beta.go
- binned.go
- binomial.go
- bootstrap.go
- cauchy.go
- chi.go
- chi2.go
- chisquare.go
- confint.go
- continuous.go
- correlation.go
- data.go
- densities.go
- describe_util.go
- dirichlet.go
- discrete.go
- doc.go
- elementary.go
- entropies.go
- entropy.go
- entropy_quad.go
- errors.go
- exponential.go
- fdist.go
- fit.go
- gamma.go
- geometric.go
- gumbel.go
- halfnormal.go
- histogram.go
- hypergeom.go
- hypergeom_internal.go
- hypergeom_rvs.go
- hypotest.go
- invert.go
- invgamma.go
- kde.go
- ks.go
- ksdist.go
- laplace.go
- loader.go
- logistic.go
- lognormal.go
- lomax.go
- moments.go
- multinomial.go
- multivariate_normal.go
- mvhelpers.go
- mvn_cdf.go
- mvspecial.go
- nbinom.go
- ncx2.go
- normal.go
- normality.go
- parallel.go
- pareto.go
- poisson.go
- quantile.go
- randint.go
- rank.go
- ranktests.go
- rayleigh.go
- reciprocal.go
- robust.go
- scipyfloat.go
- studentt.go
- triangular.go
- trigtable.go
- ttest.go
- uniform.go
- vonmises.go
- weibull.go
- zipf.go
- zz_dist_bernoulli.go
- zz_dist_beta.go
- zz_dist_binomial.go
- zz_dist_cauchy.go
- zz_dist_chi.go
- zz_dist_chisquared.go
- zz_dist_discreteuniform.go
- zz_dist_exponential.go
- zz_dist_f.go
- zz_dist_gamma.go
- zz_dist_geometric.go
- zz_dist_gumbel.go
- zz_dist_halfnormal.go
- zz_dist_hypergeometric.go
- zz_dist_inversegamma.go
- zz_dist_laplace.go
- zz_dist_logistic.go
- zz_dist_lognormal.go
- zz_dist_lomax.go
- zz_dist_negativebinomial.go
- zz_dist_noncentralchisquared.go
- zz_dist_normal.go
- zz_dist_pareto.go
- zz_dist_poisson.go
- zz_dist_rayleigh.go
- zz_dist_reciprocal.go
- zz_dist_studentt.go
- zz_dist_triangular.go
- zz_dist_uniform.go
- zz_dist_vonmises.go
- zz_dist_weibull.go
- zz_dist_zipf.go
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
dd
Package dd is a minimal double-double ("float128-lite") arithmetic used where a special function must carry more than 53 bits through an intermediate step: the argument of an exponential, a long product, a cancellation.
|
Package dd is a minimal double-double ("float128-lite") arithmetic used where a special function must carry more than 53 bits through an intermediate step: the argument of an exponential, a long product, a cancellation. |