Patterns in static

Apophenia

apop_binomial.c File Reference

Variables


Detailed Description

The binomial distribution as an apop_model.


Variable Documentation

The binomial model.

The parameters are kept in the vector element of the apop_model parameters element. parameters->vector->data[0]==n; parameters->vector->data[1]==p.

Input data can take two forms:

The default is to take the data to have a binary form, meaning that the system counts zeros as failures and non-zeros as successes. $N$ is the size of the matrix, vector, or both (whichever is not NULL).

In rank-type format, the data is taken to be the two-column miss-hit format: a nonzero value in column zero of the matrix represents a failure and a nonzero value in column one represents successes. Set this using, e.g.,

apop_model *estimate_me = apop_model_copy(apop_binomial);
Apop_model_add_group(estimate_me, apop_rank);
apop_model *estimated = apop_estimate(your_data, estimate_me);

In both cases, $p$ represents the odds of a success==1; the odds of a zero is $1-p$.

See also the apop_multinomial model.

The multinomial model.

The parameters are kept in the vector element of the apop_model parameters element. parameters->vector->data[0]==n; parameters->vector->data[1...]==p_1....

Input data can take two forms:

The default is simply a listing of bins, without regard to whether items are in the vector or matrix of the apop_data struct, or the dimensions. Here, data like 0, 1, 2, 1, 1 represents one draw of zero, three draws of 1, and one draw of 2.

In rank-type format, the bins are defined by the columns: a nonzero value in column zero of the matrix represents a draw of zero, a nonzero value in column seven a draw of seven, et cetera. Set this form using, e.g.,

apop_model *estimate_me = apop_model_copy(apop_binomial);
Apop_model_add_group(estimate_me, apop_rank);
apop_model *estimated = apop_estimate(your_data, estimate_me);

In both cases, the numeraire is zero, meaning that $p_0$ is not explicitly listed, but is $p_0=1-\sum_{i=1}^{k-1} p_i$, where $k$ is the number of bins. Conveniently enough, the zeroth element of the parameters vector holds $n$, and so a full probability vector can easily be produced by overwriting that first element. Continuing the above example:

int n = apop_data_get(estimated->parameters, 0, -1); 
apop_data_set(estimated->parameters, 0, 1 - (apop_sum(estimated->parameters)-n)); 

And now the parameter vector is a proper list of probabilities.

See also the apop_binomial model.

SourceForge.net Logo

Autogenerated by doxygen on 23 Nov 2009.