Hi, C Board
I'm writing a program to simulate dropping particles onto a random place on a 1-dimensional surface.
The heights at each point in the surface are stored in an array, and when a particle falls on a point, it increases the height at that point by one.
The program is meant to do several simulations, with the total number of particles dropped varying each time.
However, when plotted, the lines for each of these simulations clearly follows the same pattern. (see attached picture)
Does anyone know why this is happening, and how to make it not happen?
Thanks in advance, Dez.
The relevant bit of code (WIDTH is 100):
Code:
srandom( time(NULL) );
for ( drops=1000 ; drops<10000 ; drops+=1000 )
{
for ( l=0 ; l<drops ; l++ )
{
x = random();
x = x%WIDTH ;
surface[x]++ ;
}
for ( x=0 ; x<WIDTH ; x++ )
{
fprintf( p_outfile , "%lu," , surface[x] );
}
fprintf( p_outfile , "\n" );
}