我想要计算t统计量的p值,用于具有5%显著性水平的双尾检验。我想用标准库做到这一点。我想知道是否可以使用< random >模块中的student_t_distribution。我目前的代码如下
#include <iostream>
int main(){
double t_stat = 0.0267; // t-statistic
double alpha_los = 0.05; // level of significance
double dof = 30; // degrees of freedom
// calculate P > |t| and compare with alpha_los
return 0;
}谢谢
发布于 2020-08-24 23:01:10
<random>头只为您提供了从不同发行版获得随机数的能力。
如果您能够使用boost,则可以执行以下操作:
#include <boost/math/distributions/students_t.hpp>
int main() {
double t_stat = 0.0267; // t-statistic
double alpha_los = 0.05; // level of significance
double dof = 30; // degrees of freedom
boost::math::students_t dist(dof);
double P_x_greater_t = 1.0 - boost::math::cdf(dist, t_stat);
double P_x_smaller_negative_t = boost::math::cdf(dist, -t_stat);
if(P_x_greater_t + P_x_smaller_negative_t < alpha_los) {
} else {
}
}https://stackoverflow.com/questions/63558941
复制相似问题