gpt4 book ai didi

c++ - boost student_t 分布

转载 作者:行者123 更新时间:2023-11-28 00:59:05 26 4
gpt4 key购买 nike

我有以下代码:

#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/math/distributions/students_t.hpp>

using namespace boost::numeric;
using namespace interval_lib;

unsigned int len=10;
unsigned int v = len - 1;
double sqrtlen = sqrt(double(len));
students_t dist(v);
double stdev = 0.2;
double mean = 3;
double t_stat = mean * sqrtlen / stdev;
double q = cdf(complement(dist, std::fabs(t_stat)));

但是,当我编译时,出现以下错误:

Tests.cpp:39:3: error: ‘students_t’ was not declared in this scope
Tests.cpp:39:14: error: expected ‘;’ before ‘dist’
Tests.cpp:45:31: error: ‘dist’ was not declared in this scope
Tests.cpp:45:54: error: ‘complement’ was not declared in this scope
Tests.cpp:45:55: error: ‘cdf’ was not declared in this scope

我不明白为什么当我包含适当的 header 时它会提示。谁能告诉我如何解决它。谢谢!

最佳答案

因为您没有包含 good 命名空间。来自文档:

So, for example, the Students-t distribution template in namespace boost::math is

Link here

关于c++ - boost student_t 分布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9696079/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com