Re: Random numbers



quasi <quasi@xxxxxxxx> writes:
On 21 Dec 2007 16:20:58 +0200, Phil Carmody
<thefatphil_demunged@xxxxxxxxxxx> wrote:

quasi <quasi@xxxxxxxx> writes:
On 21 Dec 2007 14:53:38 +0200, Phil Carmody
<thefatphil_demunged@xxxxxxxxxxx> wrote:

quasi <quasi@xxxxxxxx> writes:
On 21 Dec 2007 14:33:08 +0200, Phil Carmody
<thefatphil_demunged@xxxxxxxxxxx> wrote:

John <iamachamp@xxxxxxxxx> writes:
Given a function that returns a random number between 1-5, write one
that returns a random number between 1-7 for the case when it should
be integer and for the case it can be real.

int rand1to7i()
{
int r1=rand1to5i();
if(r1==5) { r1+=rand1to5i()/2; }
return r1;
}

Fatally flawed.

Wrong. Care to back up your claim? Between you and me, I
reckon you've not thought about my response enough.

Yes, do a simulation, and then _you_ think about it.

What do you think the simulation will prove, and why do you
think that's important?

double rand1to7d()
{
return rand1to5d()+(rand1to5d()-1)/2;
}

Inefficient -- uses 2 RNG calls, instead of 1.

Wrong. If you stretch the numbers out, you'll leave gaps
between them, these aren't actual reals, you did realise
that, right? You *need* 2 calls to ensure that you leave
no gaps.

Forget gaps -- your method is biased!

Already responded to that irrelevancy elsewhere in the thread.

Already responded to your weak coverup ploy.

So I saw. And laughed.

Phil
--
Dear aunt, let's set so double the killer delete select all.
-- Microsoft voice recognition live demonstration
.



Relevant Pages

  • Re: Random numbers
    ... int rand1to7i() ... Yes, do a simulation, and then _you_ think about it. ... If you stretch the numbers out, you'll leave gaps ... between them, these aren't actual reals, you did realise ...
    (sci.math)
  • Re: Random numbers
    ... int rand1to7i() ... reckon you've not thought about my response enough. ... If you stretch the numbers out, you'll leave gaps ... between them, these aren't actual reals, you did realise ...
    (sci.math)
  • Re: Random numbers
    ... int rand1to7i() ... reckon you've not thought about my response enough. ... If you stretch the numbers out, you'll leave gaps ... between them, these aren't actual reals, you did realise ...
    (sci.math)
  • Re: Random numbers
    ... int rand1to7i() ... If you stretch the numbers out, you'll leave gaps ... between them, these aren't actual reals, you did realise ...
    (sci.math)
  • [PATCH] Cleanups for the IPMI driver
    ... off the shutdown of the timer when removing the module. ... static int ipmi_init_msghandler; ... * Send a command request from the given user. ... * the message response comes back, the receive handler for this user ...
    (Linux-Kernel)