Simulations of junk and stuff is hard yo.

today was the day that evan, greg, ben, and i sat down and coded the monte carlo simulator for 22.55. i learned just how hard it is to get C to generate random numbers. not because there is something particularly challenging about generating a string of pseudo-random numbers, but because C is both really anal and ambiguous about data types and passing information between functions.

i swear, i had code in one function that was generating random numbers between 0 and 1 that were actually numbers in the hundred-billions. i copied the code from one place to another and it worked fine. i don't understand it.

everyone should just code in perl. perl will return nice random numbers of great "randomness" with the following two lines:


srand(time()^($$+($$<<15)));
$myRandomNumber = rand(1);

the equivalent C code is about 15-20 lines long, and was too difficult for evan and i to figure out. granted, i'm no C guru, but evan supposedly is. we almost resorted to using a perl script to choose our random seed for us, but we couldn't get the output from the perl piped into the C program properly because C was bitchy about where the data went.

so, the moral of this story is that i like perl and C blows.

so what if the equivalent simulation in perl would have taken about 1500x as long? blow me.

there's nothing unusual about having to wait around my room for three hours for my advisor to call, but on a saturday? blow. i had to skip a trip to walden pond to wait for his call, which he said would be around 4:30. he ends up calling me at 7:30, half an hour after the walden group got back. !$&#@

on a related topic, my turbulence simulation is not ready for presentation.

i'm supposed to have a paper on it handed in on tuesday, and a 25 minute presentation on thursday. but right now i don't even know how it works, let alone have any meaningful data...

"Simulations of junk and stuff is hard yo." Comments

Post a comment
Name Required
Email Required

URL
Remember info
Yes No

Comment Required


Type the characters you see in the picture above.