I don't know if I am implementing this correctly. I created a function called boosted that returns the float for the given value but I am getting this error.
terminate called after throwing an instance of
'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::domain_error> >'
what(): Error in function boost::math::cdf(const chi_squared_distribution<double>&, double): Chi Square parameter was -nan, but must be > 0 !
Aborted
Can someone explain why I am getting this and how to get it to work? I've provided my teacher's website http://staffwww.fullcoll.edu/aclifton/cs133/assignment5.html and my code for the function.
float boosted (vector <int>& v){
float c2 = 0;
float numWords = v.size()/65536;
for(int i = 0; i < v.size(); i++)
c2 = pow(numWords - v[i], 2)/numWords;
boost::math::chi_squared c2d(65535.0);
return boost::math::cdf(c2d, c2);
}