Re: Simple optimization

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Bob Cummings wrote:
Nick Hounsome wrote:
"Bob Cummings" <rancho@xxxxxxxx> wrote in message news:445D1A0F.20504@xxxxxxxxxxx



Regarding your simulation - you clearly haven't thought out exactly what you want because the integer range 0-100 contains only 101 discreete values whereas 0.0-1.0 contains something like 999999999999 in a double.

I understand the idea of more possible values in a 0.0 ~ 1.0 vs. 0 ~ 100 I just do not have the knowledge and experience on how to express myself. I guess the point I was trying to make was the scientist do not require a finer scale then 1 - 100. Hope that make sense.

Your
random number generation could well be the most expensive operation so knowing what you need is very important. Ideally you could get away with just using a relatively small array of precomputed random numbers.

Again my ignorance is showing here. I think you are suggesting in the beginning of the program to generate say 10,000 random numbers and put them in an array. Then as the program progresses just grab the next number in the array. When I run out then fill the array again?

I think that Nick was thinking more in the line of creating the array once, and use it over and over again. If you just refill the array after using it once, there is no performance gain. On the contrary it uses more operations and more memory to do the same thing.

There is a risk with reusing random numbers, though. If the size of the array is too small so that you reuse the same numbers many times, you might begin to see patterns in the simulation.

I can see how that would work especially since between each year time period there are maintenance issues such as witting output files and loading the next years maps. I am not very versed in using multi threads and call backs but this might be a case for that?

As the task in itself doesn't need multi threading to work, using it would only add complexity and overhead.

Beware the pitfalls of using just the low bits of a simple integer random number generator.

Here I am completely lost on your advice?

That also has to do with patterns. A simple integer random generator has a simple and predictable algorithm. If you use the lower bits of the value you will se reaccuring series of numbers.
.


Quantcast