normal distribution - C++11 normal_distribution and MATLAB normpdf -


i have develop normpdf matlab function in c++ environment. got problem..

normpdf(x, u, sigma) in matlab similar normal_distribution gaussian(u, sigma);

where x values? means want gaussian function not gaussian random. how sample output value gaussian distribution?

thanks.

you write normpdf yourself

inline double squared(double x) {     return x*x; }  double normpdf(double x, double u, double s) {      return (1.0/(s*sqrt(2.0*m_pi)))*exp(-0.5*squared(x-u)/squared(s)); } 

update

this 1 might bit faster, less 1 multiplication

const double one_over_sqrt_2pi = 0.39894228040143267793994605993438;  double normpdf(double x, double u, double s) {      return (one_over_sqrt_2pi/s)*exp(-0.5*squared((x-u)/s)); } 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -