Patterns in static

Apophenia

Calculate moments (mean, var, kurtosis) for the data in a gsl_vector.

Defines

Functions


Detailed Description

These functions simply take in a GSL vector and return its mean, variance, or kurtosis; the covariance functions take two GSL vectors as inputs.

apop_vector_kurtosis and apop_vector_kurt are identical; pick the one which sounds better to you.

See also:
db_moments

For apop_vector_var_m(vector, mean), mean is the mean of the vector. This saves the trouble of re-calcuating the mean if you've already done so. E.g.,

gsl_vector *v;
double mean, var;

//Allocate v and fill it with data here.
mean = apop_vector_mean(v);
var  = apop_vector_var_m(v, mean);
printf("Your vector has mean %g and variance %g\n", mean, var);

Define Documentation

#define apop_mean ( in   ) 

An alias for apop_vector_mean. Returns the mean of the data in the given vector.

Returns the mean of the elements of the vector v.

#define apop_var ( in   )     apop_vector_var(in)

An alias for apop_vector_var. Returns the variance of the data in the given vector.

#define apop_vector_kurt ( in   )     apop_vector_kurtosis(in)

Returns the sample kurtosis (divide by $n-1$) of the data in the given vector. This does not normalize the output: the kurtosis of a ${\cal N}(0,1)$ is three, not zero.

An alias for apop_vector_kurtosis.

#define apop_vector_mean ( in   ) 

Returns the mean of the data in the given vector.

Returns the mean of the elements of the vector v.

#define apop_vector_var ( in   ) 

Returns the variance of the data in the given vector.

This uses (n-1) in the denominator of the sum; i.e., it corrects for the bias introduced by using $\bar x$ instead of $\mu$.

At the moment, there is no var_pop function. Just multiply this by (n-1)/n if you need that.

Returns the sample variance of the elements of the vector v.


Function Documentation

double apop_vector_correlation ( const gsl_vector *  ina,
const gsl_vector *  inb 
)

Returns the correllation coefficient of two vectors. It's just $ {\hbox{cov}(a,b)\over \sqrt(\hbox{var}(a)) * \sqrt(\hbox{var}(b))}.$

double apop_vector_cov ( const gsl_vector *  ina,
const gsl_vector *  inb 
)

Returns the covariance of two vectors

double apop_vector_kurtosis ( const gsl_vector *  in  ) 

Returns the sample kurtosis (divide by $n-1$) of the data in the given vector. Corrections are made to produce an unbiased result.

This does not normalize the output: the kurtosis of a ${\cal N}(0,1)$ is three $\sigma^4$, not three, one, or zero.

double apop_vector_kurtosis_pop ( const gsl_vector *  in  ) 

Returns the population kurtosis ($\sum_i (x_i - \mu)^4/n)$) of the data in the given vector.

Some people like to normalize the skew by dividing by variance squared, or by subtracting three; those things are not done here, so you'll have to do them separately if need be.

double apop_vector_skew ( const gsl_vector *  in  ) 

Returns an unbiased estmate of the sample skew (population skew times y $n^2/(n^2-1)$) of the data in the given vector.

double apop_vector_skew_pop ( const gsl_vector *  in  ) 

Returns the population skew $(\sum_i (x_i - \mu)^3/n))$ of the data in the given vector.

Some people like to normalize the skew by dividing by variance$^{3/2}$; that's not done here, so you'll have to do so separately if need be.

double apop_vector_var_m ( const gsl_vector *  in,
const double  mean 
)

Returns the variance of the data in the given vector, given that you've already calculated the mean.

Parameters:
in the vector in question
mean the mean, which you've already calculated using apop_vector_mean.

SourceForge.net Logo

Autogenerated by doxygen on 23 Nov 2009.