Skip to content
MthwRobinson edited this page Dec 21, 2014 · 1 revision

Statistics Procedures

APPLPy statistics procedures enable users to estimate parameters given a random variable model, as well as compute a variety of test statistics.

Kolmogorov-Smirnoff Test

The KSTest procedure returns the Kolmogorov-Smirnoff test statistic, given a data set and a random variable model. In this procedure, the random variable, X, must be fully specified.

Syntax

KSTest(X,[data])

Examples:

In [3]: X=NormalRV(2,2)

In [4]: data=X.variate(n=30)

In [5]: KSTest(X,data)
Out[5]: 0.966222666749579

Maximum Likelihood Estimation

The MLE procedure returns the maximum likelihood estimate for a list of variables given a data set. The censor variable is a binary list corresponding to the data set where 1 indicates an observed value and 0 indicates a right censored variable. If the user specifies the option numeric=True, MLE will use a numeric solver to compute the maximum likelihood estimates rather than trying to solve them analytically. If the numeric option is used, the user must enter an initial guess for the values of the parameters. The MLE procedure is hard-coded with the maximum lieklihood estimates for common distributions (such as the normal distribution).

Syntax

MLE(X,[data],[parameters],[censor],guess=None,numeric=False)

Examples:

In [7]: mu=Symbol('mu')

In [8]: sigma=Symbol('sigma',positive=True)

In [9]: X=NormalRV(mu,sigma)

In [10]: data=NormalRV(0,2).variate(n=40)

In [11]: MLE(X,data,[mu,sigma])
Out[11]: [-0.0514071514600617, 1.59408965313016]

Method of Moments

The MOM procedures returns estimates for a list of unknown parameters using the method of moments. For a random variable model with n unknown parameters, the nth moment of the random variable model is set equal to the nth moment of the data set. These equations are then solved to produce parameter estimates. If the user specifies the option numeric=True, MOM will use a numeric solver to compute the parameter estimates rather than trying to solve them analytically. If the numeric option is used, the user must enter an initial guess for the values of the parameters.

Syntax

MOM(X,[data],[parameters],guess=None,numeric=False)

Examples:

n [33]: theta=Symbol('theta',positive=True)

In [34]: kappa=Symbol('kappa',positive=True)

In [35]: W=WeibullRV(theta,kappa)

In [36]: data=WeibullRV(2,4).variate(n=40)

In [37]: MOM(W,data,[theta,kappa],guess=[2.2,3.8],numeric=True)
Out[37]: 
matrix(
[['1.97128209981869'],
 ['4.4588750939415']])