Ejemplo n.º 1
0
	private: value_type do_half_width() const
	{
		if (this->num_observations() > 1)
		{
			uint_type n(this->num_observations());
			::dcs::math::stats::students_t_distribution<value_type> t_dist(n-1);
			value_type t(::dcs::math::stats::quantile(t_dist, (1+this->confidence_interval())/value_type(2)));
			value_type q(this->estimate());

			return t*::std::sqrt(q*(1-q)/(this->num_observations()-1));
		}
		return ::dcs::math::constants::infinity<value_type>::value;
	}
Ejemplo n.º 2
0
	private: value_type do_half_width() const
	{
		if (count_ > 1)
		{
			::dcs::math::stats::students_t_distribution<value_type> t_dist(count_-1);
			value_type t = ::dcs::math::stats::quantile(t_dist, (value_type(1)+ci_level_)/value_type(2));

			//return ::std::sqrt(this->variance()/count_)*t;
			return t*(this->standard_deviation()/::std::sqrt(count_));
		}

		//return value_type/*zero*/();
		return ::dcs::math::constants::infinity<value_type>::value;
	}
Ejemplo n.º 3
0
double TConfidenceInterval(double stddev, int size, double p) {
    boost::math::students_t t_dist(size - 1);
    double t_val = boost::math::quantile(
                       boost::math::complement(t_dist, (1 - p) / 2));
    return t_val * stddev / sqrt(size);
}