test_b002.cpp
来自「非常著名的曲线拟合程序」· C++ 代码 · 共 46 行
CPP
46 行
#include <iostream>#include <math.h>#include <specfns.h>using namespace std;/* Test the inv_normal_cdf() function.*/int main(){ int fail = 0; double max_err = 0; for(int i=-50; i<=50; ++i) { double x = i/10.0; double nx = normal_cdf(x); double inx = inv_normal_cdf(nx); double ninx = normal_cdf(inx); cout << x << " " << inx << " " << inx-x << " "; double err = fabs(inx-x); if (err > max_err) max_err = err; if (err > 1e-10) { cout << "failed"; ++fail; } cout << endl; cout << nx << " " << ninx << " " << nx-ninx << " "; err = fabs(nx-ninx); if (err > max_err) max_err = err; if (err > 1e-10) { cout << "failed"; ++fail; } cout << endl; } cout << "max error = " << max_err << endl; cout << "result: " << fail << " failures." << endl; return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?