> No games programmers use real randomness. You *absolutely > will* get long strings of good or bad numbers based only > on luck. Generating good psuedo-random numbers is a an > art, but the basis of that art is ensuring for an EQUAL > biasing of all samples. In other words, if you take 100 > samples, about 10 should be under 10%. About 10 should > be from 10% to 20%, etc etc. This is vitally important > in the real world. I other words, you want white noise that is high pass filtered. > With a pwm dependant on the random number, it is quite > possible that in 1000 samples (1 second?) that all the > random samples will be low. No, quite improbable actually. If "low" is defined as below 1/2, then the probability of any one number being low is 1/2. The probability of any 1000 numbers all being low is 2**-1000, which so extremely improbable as to be "impossible" in a practical sense. However, I do agree with the point your are trying to make, which I believe is that there is no guaranteed lower frequency bounds in a truly random signal. > Using a high frequency > sawtooth style wave sampled at irregular frequency or the > appropriate aliasing frequency will give a more predictable > and much more reliable result than a true random waveform > which sould be high or low for an unlimited number of cycles > based upon luck. I disagree, since you are sampling the sawtooth at random times, the result will be a random value. If you don't sample at regular intervals, then you will get aliasing, which could again lead to arbitrarily low frequency content. Throwing in the sawtooth (or any other waveform that contains all levels equally) obscures what is going on a bit, but you end up with the same situation. You could sample your sawtooth using a Poisson interval method with a properly chosen upper period. That would eliminate all low frequencies below a cutoff. The power that would go into aliases with regular sampling turns into white noise above the cutoff frequency. However this method requires sampling the sawtooth at precisely determined times, which defeats the purpose. > If the sawtooth frequency is significantly higher than > the sampling frequency, the result will be very random > with excellent weighting. As mentioned before, this gets you nowhere. If you sample regularly you get aliasing. If you sample randomly, you are back to a purely random number generator. This "sawtooth" concept just doesn't work. > For a timing-insensitive pwm I really think this would be > a better method. Yes, you have to deal with aliasing, but > is that a bigger problem than the alternatives?? Yes. At least with white noise the average power in the low frequencies was bounded. With aliasing the upper bound on low frequency power is higher, and the lowest possible frequency is still not bounded. > PS. The preferred way to generate good psuedo random > numbers is to generate numbers between 0 and 255 (for > eaxample) and place in a 256 unit lookup table where > there is only ONE of each number, but the postions > are random. Then you can read 256 random numbers > in sequence and have perfect weighting. This is no different from the sawtooth concept. This is just another example of a periodic signal that contains all levels equally. The only difference is that the order of the samples has changed, which makes no difference to the way we are discussing using the signal. ***************************************************************** Olin Lathrop, embedded systems consultant in Devens Massachusetts (978) 772-3129, olin@embedinc.com, http://www.embedinc.com -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.