
Hello everybody, I have to implement the Pearson chi-square test in C++. I do not succeed in finding the appropriate instructions to use boost for this purpose. I am not even sure of the library file I ought to use. Many thanks in advance for any help. Best regards, Christine Sinoquet // convention: // df: degrees of freedom // css_observed: observed chi-squared score #include <boost/accumulators/statistics/stats.hpp> void chi_squared_test(){ typedef accumulator_set<double, stats<tag::p_square_cumulative_distribution> > accumulator_t; accumulator_t acc(tag::p_square_cumulative_distribution::<???tag in connexion with df (degrees of freedom)???>); double p = acc(<access to cumulative function for css_observed>) ... } _________________________________________________________________________________ Note 1: As far as I can see, the code below found on Internet does not correspond at all to my boost library : // df: degrees of freedom // css_observed: observed chi-squared score boost::math::chi_squared mydist(df); // usage of the cdf accessor function (cumulative distribution function) to compute the p-value // corresponding to the observed chi-squared score with df degrees of freedom. // p(css <= css_observed) = F(css_observed) float p = boost::math::cdf(mydist,css_observed); // p-value = 1 - p is the probability of observing a chi-squared score at least as extreme as css_observed, // if one assumes the null hypothesis holds. ___________________________________________________________________________________ Note 2: Below is the content of .../boost/include/boost/accumulators/statistics : count.hpp covariance.hpp density.hpp directory error_of.hpp error_of_mean.hpp extended_p_square.hpp extended_p_square_quantile.hpp kurtosis.hpp max.hpp mean.hpp median.hpp min.hpp moment.hpp parameters peaks_over_threshold.hpp pot_quantile.hpp pot_tail_mean.hpp p_square_cumulative_distribution.hpp p_square_quantile.hpp skewness.hpp stats.hpp sum.hpp tail.hpp tail_mean.hpp tail_quantile.hpp tail_variate.hpp tail_variate_means.hpp times2_iterator.hpp variance.hpp variates weighted_covariance.hpp weighted_density.hpp weighted_extended_p_square.hpp weighted_kurtosis.hpp weighted_mean.hpp weighted_median.hpp weighted_moment.hpp weighted_peaks_over_threshold.hpp weighted_p_square_cumulative_distribution.hpp weighted_p_square_quantile.hpp weighted_skewness.hpp weighted_sum.hpp weighted_tail_mean.hpp weighted_tail_quantile.hpp weighted_tail_variate_means.hpp weighted_variance.hpp with_error.hpp