Richard D. Moores wrote:
Actually, I used the unfair coin model as the simplest example of the kind of thing I want to do -- which is to model the USD->Yen exchange rate. I want the next quote to vary in a controlled random way, by assigning probabilities to various possible changes in the rate. See <http://tutoree7.pastebin.com/mm7q47cR>. So I assign probability 1/40 to a change of plus or minus .05; 3/40 to .04; 5/40 to .03, etc.
Another approach you might take is to model the change as a normal distribution (bell curve probability) rather than uniform. This is probably more realistic. It would make most sense to have it symmetrical around zero, so you want a random number with a normal distribution, a mean of zero, and a standard deviation yet to be determined.
To determine the standard deviation, use this rule of thumb: for a normal (bell) curve, approximately 68% of events are plus or minus one standard deviation from the mean; 95% are plus or minus two std deviations; and 99.7% are plus or minus three std deviations.
So if you decide that 99.7% of the time the change in exchange rate should be less than 1.00, for example, that corresponds to a std deviation of 0.333.
You then generate a normally-distributed value using the random module, round it to two decimal places to correspond to cents, and Bob's your uncle.
-- Steven _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor