|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Invisible nous apporta ses lumieres en ce 2007/11/26 05:36:
> OK, so unlike the Euler project, *this* question has some practical use.
> ;-)
>
> Anybody have any idea how I can make a program generate random numbers
> between 30 and 30,000, but so that "most" of the numbers generated are
> actually in the range 100 - 400?
A possibility: Use the division of some random numbers. The divider must have a
range starting at 1.
Samples: rand(X)*29970/(rand(X)*Z+1)+30
(rand(X)+rand(X))*14985/(rand(X)*Z+1)+30
--
Alain
-------------------------------------------------
Everybody should believe in something: I believe I'll have another drink.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Warp wrote:
> Invisible <voi### [at] devnull> wrote:
>> Anybody have any idea how I can make a program generate random numbers
>> between 30 and 30,000, but so that "most" of the numbers generated are
>> actually in the range 100 - 400?
>
> http://en.wikipedia.org/wiki/Poisson_distribution
I'd have used a Gaussian - any particular reason to choose a Poisson?
--
Isn't it counterproductive to have incandescent bulbs in a fridge?
/\ /\ /\ /
/ \/ \ u e e n / \/ a w a z
>>>>>>mue### [at] nawazorg<<<<<<
anl
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Mueen Nawaz wrote:
> Warp wrote:
>> Invisible <voi### [at] devnull> wrote:
>>> Anybody have any idea how I can make a program generate random numbers
>>> between 30 and 30,000, but so that "most" of the numbers generated are
>>> actually in the range 100 - 400?
>> http://en.wikipedia.org/wiki/Poisson_distribution
>
> I'd have used a Gaussian - any particular reason to choose a Poisson?
100 and 400 are both nearer to 30 than to 30,000?
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Depends on how efficient or accurate it needs to be.
A simple but inefficient way is to create a curve
function that represents the desired distribution,
generate two random numbers representing an
X,Y vector on the chart, then reject the points
above the curve, and use the X value of accepted
points as the random value.
An efficient but more complicated method is
to create a bar graph approximation of the
distribution curve, then "stack" the rectangles.
Then you can create an X,Y vector guaranteed
to be inside the stack of rectangles, then figure
the X offset of the rectangle based on Y and
use X + X offset @ Y as your random value.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Invisible wrote:
> scott wrote:
>
>> #if( rand(s1) < 0.1 )
>> #local N = rand(s1) * 29970 + 30;
>> #else
>> #local N = rand(s1) * 300 + 100;
>> #end
>
> Mmm, yeah, I guess that would work. :-)
I saw the question, came to the same answer, and anticipated the same
response, even it had been in haskell. Don't you have some flirting you
should be catching up with?
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Tom Galvin wrote:
> I saw the question, came to the same answer, and anticipated the same
> response, even it had been in haskell. Don't you have some flirting you
> should be catching up with?
That requires a partner. :-P
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Invisible wrote:
> Tom Galvin wrote:
>
>> I saw the question, came to the same answer, and anticipated the same
>> response, even it had been in haskell. Don't you have some flirting
>> you should be catching up with?
>
> That requires a partner. :-P
You could always flirt with yourself. Mind you don't go blind, though.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Bill Pragnell wrote:
> You could always flirt with yourself. Mind you don't go blind, though.
Oh that's cute. :-P
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
474d8e1d$1@news.povray.org...
>
> You could always flirt with yourself. Mind you don't go blind, though.
Let's not forget the kittens
http://en.wikipedia.org/wiki/Image:God-kills-kitten.jpg
Marc
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
M_a_r_c wrote:
> Let's not forget the kittens
http://lolcat.com/godkills.html
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |