Go Down

Topic: How do I filter a RNG output to produce biased numbers? (Read 330 times) previous topic - next topic

orangestick

Hi all,
I am using a random number generator to determine when the Arduino should emit a pulse.
Random means that the frequency distribution of pulses in the output is approximately equal. There's as much 1Hz content in the output as there is 1000Hz content in the output: pulses happen once a second just as much as they do a thousand times a second.
I want the frequency distribution to roll off evenly, with a flat NdB/octave slope. I would also like to be able to bandpass filter it, so that the pulses tend to happen at 500Hz but also happen quite frequently at other times as well. Is this possible?

MaJiG

You need to rethink your basic premise, methinks. You can produce a 1KHz tone for one second, but you can't produce a 1Hz tone for 1/1000th of a second, yes?

Can you re-define your requirements for us? Are you trying to produce white noise?

BTW, what is RNG?

robtillaart

suppose your RNG generates between 1 and 1000 you can feed that number to a function that reformats the distribution.

e.g.

float x = random(1,1000);
float y = 1 + 100*exp(x/500);  // 101 .. 739
float z = exp(10/x);  // 22000 .. 1

to get another distribution.

float x = random(1,1000);
float y = x + (x/2?10*sin(x):1000/x;  // usefulness of this one has to be investigated :)

get the idea?

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

lloyddean


PeterH

I'm not sure what you intend the bandpass filter to do, but the rest of what you're describing is achievable by applying a transform to the uniform random number in your input domain to convert it into your output domain. Conceptually, if you were to plot the input and output values of that transform then the slope of the plot at a given output value would give you the probability density at that output value - if you see what I mean?
I only provide help via the forum - please do not contact me for private consultancy.

Go Up