![]() |
|
The binomial distribution as an apop_model.
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.
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,
represents the odds of a success==1; the odds of a zero is
.
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
is not explicitly listed, but is
, where
is the number of bins. Conveniently enough, the zeroth element of the parameters vector holds
, 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.