SHARE
TWEET

Normal distribution

a guest Jun 9th, 2011 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <boost/math/distributions/normal.hpp>
  2. #include <iostream>
  3. #include <fstream>
  4. using namespace boost::math;
  5. using namespace std;
  6. int main(){
  7.         int max=512;
  8.         int il=550;
  9.         normal_distribution<double> nd;
  10.         int table[max];
  11.         std::fstream faa("helper.txt",ios_base::out|ios_base::binary);
  12.         for (int i=1; i<max; i++)
  13.                 table[i]=(int)(quantile(nd,i/(max*1.0))*il);
  14.         int min=table[1];
  15.         int mmax=table[max-1];
  16.         faa.write((char*)&max,4);
  17.         faa.write((char*)&il,4);
  18.         double dmax=int((quantile(nd,(max-1)/(max*1.0))*il))/(il*1.0);
  19.         double dmin=int((quantile(nd,1/(max*1.0))*il))/(il*1.0);
  20.  
  21.         faa.write((char*)&dmin,8);
  22.         faa.write((char*)&dmax,8);
  23.         int writhe=mmax-min;
  24.         faa.write((char*)&writhe,4);
  25.         int* curr=table+1;
  26.         for(int i=0; i<mmax-min; i++){
  27.                 if (i+min>*curr) {
  28.                         curr++;
  29.                 }
  30.                 int p=(curr-table);
  31.                 cout<<i<<' '<<p<<endl;
  32.                 faa.write((char*)&p,4);
  33.         }
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top