Skip to content
Rafat Hussain edited this page Apr 25, 2015 · 5 revisions

Some helpful Statistical and Probability Distribution functions

N length of the input data Normal Distribution assumed.

double mean(double* vec, int N); // Returns mean

double var(double* vec, int N);// Returns Variance

M Length of the covariance/correlation vector. The maximum lag is M-1 or N-1 , whichever is smaller.

void autocovar(double* vec, int N, double* acov, int M);

Returns autocovariance vector of length min(M-1,N-1) If M > N , the program will indicate the new length of the returned vector

void autocorr(double* vec, int N, double* acorr, int M);

Returns autocorrelation vector of length min(M-1,N-1) If M > N , the program will indicate the new length of the returned vector

Probability Distributions (pdf,cdf and inverse cdf)

1. Normal Distribution

double normalpdf(double x, double mu, double sigma);

double normalcdf(double x, double mu, double sigma);

double normalinv(double p, double mu, double sigma);

2. Student's T Distribution

double tpdf(double t, int df);

double tcdf(double t, int df);

double tinv_appx(double p, int df);

double tinv(double p, int df);

3. F Distribution

double fpdf(double x, int k1, int k2);

double fcdf(double x, int k1, int k2);

double finv(double p, int k1, int k2);

4. Gamma Distribution

double gammapdf(double x, double k, double th);

double gammacdf(double x, double k, double th);

double gammainv(double p, double k, double th);

5. Chi-squared Distribution

double chipdf(double x, int df);

double chicdf(double x, int df);

double chiinv(double p, int df);

Reference : Milton Abramowitz, I.A. Stegun, Handbook of Mathematical Functions. (Dover Books on Mathematics)

Clone this wiki locally