⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cum_normal.cc

📁 Financial Recipes
💻 CC
字号:
// numerical approximations to univariate N(z) cumulative normal distribution#include <cmath>     // math functions.using namespace std;double N(double z) {// This is a numerical approximation to the normal distribution.  // See Abramowitz and Stegun: Handbook of Mathemathical functions// for description.  The arguments to the functions are assumed // normalized to a (0,1 ) distribution.     if (z >  6.0) { return 1.0; }; // this guards against overflow     if (z < -6.0) { return 0.0; };    double b1 =  0.31938153;     double b2 = -0.356563782;     double b3 =  1.781477937;    double b4 = -1.821255978;    double b5 =  1.330274429;     double p  =  0.2316419;     double c2 =  0.3989423;     double a=fabs(z);     double t = 1.0/(1.0+a*p);     double b = c2*exp((-z)*(z/2.0));     double n = ((((b5*t+b4)*t+b3)*t+b2)*t+b1)*t;     n = 1.0-b*n;     if ( z < 0.0 ) n = 1.0 - n;     return n; };

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -