math - Generate a Random Number within a Range -


I have done this before, but now I am struggling again with it, and I think that I Did not understand the issue

I want to set a random number within a small border on either side of 1 . Examples will be .98 , 1.02 , .94 , 1.1 , etc. I 0 And there is a random number between 100 , but how can I use it to get within that range?

The programming language is not really the thing here, though I am using pure data, would anybody please explain mathematics?

uniform

if you want (Psuedo-) equal distribution (parallel distance ) Is between 0.9 and 1.1, then the following will work:

  category = 0.2 returns 1-range / 2 + rand (100) * range / 100  
< P> Adjust the range accordingly

pseudo-general

If you wanted normal distribution (bell curve) then you will need special code, which will be special in language / library. Get a close approximation with Can be:

  sd = 0.1 means = 1 count = 10 for sum = 0 (int i = 1; i & lt; count; i ++) sum = sum + (rand) (100) -50)} General = sum / count = General * SD + meaning  

Comments

Popular posts from this blog

MVP, design question -

excel - Populate list via a bi-Condition -

iphone - How do I make a UIPickerView in a UIActionSheet -