in reply to Re^4: Randomly biased, random numbers.
in thread Randomly biased, random numbers.
You more or less have it.
I haven't a clue how I'd go about it though :( (Offers?:)For my standard consulting rate? ;-)
Basically, you want to take a uniform distribution between 0 and M, and map it to a non-uniform one between 0 and N, so that X+I < X+J when I < J. One way to do this is to generate a step-functionpiecewise linear function, then translate values through that step function. In Matlab, it looks something like this for a 10-step function:
Using a spline would be more complicated, but would be smoother.fx = [0,cumsum(unifrnd(0,1,1,10))]; tmp=unifrnd(1,10,1,1e5); ix=floor(tmp); dx=rem(tmp,1); values = (fx(ix) + (fx(ix+1)-fx(ix)).*dx)./fx(end-1);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: Randomly biased, random numbers.
by BrowserUk (Patriarch) on Dec 06, 2013 at 06:57 UTC | |
by educated_foo (Vicar) on Dec 06, 2013 at 07:04 UTC | |
by BrowserUk (Patriarch) on Dec 06, 2013 at 09:13 UTC | |
by educated_foo (Vicar) on Dec 06, 2013 at 19:48 UTC | |
by BrowserUk (Patriarch) on Dec 06, 2013 at 20:30 UTC | |
|
In Section
Seekers of Perl Wisdom