generate_gaussian_1d.cpp
Go to the documentation of this file.
00001 #include <cmath>
00002 #include <cstdio>
00003 #include <cstdlib>
00004 
00005 #define E 2.71828183
00006 #define PI 3.14159265
00007 
00008 double g(double x, double stddev)
00009 {
00010   return (1.0 / (sqrt(2 * PI) * stddev)) * pow(E, -((x*x)/(2*stddev*stddev)));
00011 }
00012 
00013 int main(int argc, char** argv)
00014 {
00015   int bound = atoi(argv[1]);
00016 
00017   double sum = 0;
00018 
00019   for (int i = -bound; i <= bound; ++i)
00020     {
00021       double val = g(i, atof(argv[2]));
00022       printf("%f,\n", val);
00023 
00024       sum += val;
00025     }
00026 
00027   printf("sum: %f\n", sum);
00028 }


rve_render_server
Author(s): Josh Faust
autogenerated on Wed Dec 11 2013 14:31:15