![]() |
|
Functions | |
apop_model * | apop_model_to_pmf (apop_model *model, apop_data *binspec, long int draws, int bin_count, gsl_rng *rng) |
apop_data * | apop_histograms_test_goodness_of_fit (apop_model *observed, apop_model *expected) |
apop_data * | apop_test_kolmogorov (apop_model *m1, apop_model *m2) |
apop_data* apop_histograms_test_goodness_of_fit | ( | apop_model * | observed, |
apop_model * | expected | ||
) |
Test the goodness-of-fit between two apop_pmf models.
If you send two histograms, I assume that the histograms are synced: for PMFs, you've used apop_data_to_bins to generate two histograms using the same binspec, or you've used apop_data_pmf_compress to guarantee that each observation value appears exactly once in each data set.
In any case, you are confident that all values in the observed
set appear in the expected
set with nonzero weight; otherwise this will return a statistic of
GSL_POSINF
, indicating that it is impossible for the observed
data to have been drawn from the expected
distribution.
apop_opts.verbose >=1
I will show a warning. apop_model* apop_model_to_pmf | ( | apop_model * | model, |
apop_data * | binspec, | ||
long int | draws, | ||
int | bin_count, | ||
gsl_rng * | rng | ||
) |
Make random draws from an apop_model, and bin them using a binspec in the style of apop_data_to_bins. If you have a data set that used the same binspec, you now have synced histograms, which you can plot or sensibly test hypotheses about.
The output is normalized to integrate to one.
binspec | A description of the bins in which to place the draws; see apop_data_to_bins. (default: as in apop_data_to_bins.) |
model | The model to be drawn from. Because this function works via random draws, the model needs to have a draw method. (No default) |
draws | The number of random draws to make. (arbitrary default = 10,000) |
bin_count | If no bin spec, the number of bins to use (default: as per apop_data_to_bins, ![]() |
rng | The gsl_rng used to make random draws. (default: an RNG from apop_rng_get_thread) |
apop_data* apop_test_kolmogorov | ( | apop_model * | m1, |
apop_model * | m2 | ||
) |
Run the Kolmogorov-Smirnov test to determine whether two distributions are identical.
m1 | A sorted PMF model. I.e., a model estimated via something like |
m2 | Another apop_model. If it is a PMF, then I will use a two-sample test, which is different from the one-sample test used if this is not a PMF. |
out->error='m' | Model error: m1 is not an apop_pmf. I verify this by checking whether m1->cdf == apop_pmf->cdf . |
m1
and m2
are identical.Here is an example, which tests whether a set of draws from a Normal(0, 1) matches a sequence of Normal distributions with increasing mean.