I am generating the random numbers in a domain by using the following code. When I plot them they look grouped at the right. I could show you my plot but I do not know how to upload it. Basically I associate a some data value to the respective point. May you tell me how can I correct it please? My complete code is
#include <iostream>
#include <cmath>
#include <fstream>
#include <sstream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <time.h>
using namespace std;
string int2string1( int l );
string int2string2( int m );
int main ()
{
ofstream outFile;
ofstream myimp;
string filename;
srand((unsigned)time(0));
int nx = 400;
int ny = 200;
int i,j,ix,iy,xm,ym,nimp,nfam[nx][ny];
float vo,rnd,rr,rad,sig,vimp[nx][ny];
for (i=0; i<nx; i++)
{
for (j=0; j<ny; j++)
{
vimp[i][j] = 0.0;
}
}
rad = 5.0;
xm = 0;
ym = 0;
vo = 0.08;
sig = 4.0;
myimp.open("imp.dat");
for(i=1; i<nx-1; i++)
{
for(j=1; j<ny-1; j++)
{
rnd = (random() %1000 + 1)*1.0/1000.0;
if(rnd>0.99)
{
xm = random() % 398 + 1; /***1 through 399 ***/
ym = random() % 198 + 1; /***1 through 199 ***/
for(ix=xm-5; ix<=xm+5; ix++)
{
for(iy=ym-5; iy<=ym+5; iy++)
{
rr = sqrt(pow(ix-xm,2.)+pow(iy-ym,2.));
if(rr<=rad)
{
vimp[ix][iy] = vo*1.6e-19;
}
}
}
}
myimp<<i<<"\t\t"<<j<<"\t\t"<<xm<<"\t\t"<<ym<<"\t\t"<<nfam[i][j]<<"\t\t"<<vimp[i][j]*6.23e18<<"\n";
}
}
myimp.close();
return 0;
}