quasi
Posts:
12,062
Registered:
7/15/05


Re: Random numbers
Posted:
Dec 21, 2007 10:46 AM


On Fri, 21 Dec 2007 09:17:44 0500, quasi <quasi@null.set> wrote:
>On Fri, 21 Dec 2007 08:13:37 0500, quasi <quasi@null.set> wrote: > >>On 21 Dec 2007 14:53:38 +0200, Phil Carmody >><thefatphil_demunged@yahoo.co.uk> wrote: >> >>>quasi <quasi@null.set> writes: >>>> On 21 Dec 2007 14:33:08 +0200, Phil Carmody >>>> <thefatphil_demunged@yahoo.co.uk> wrote: >>>> >>>> >John <iamachamp@gmail.com> writes: >>>> >> Given a function that returns a random number between 15, write one >>>> >> that returns a random number between 17 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. >> >>>> >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! > >Ok, your method for the real case is not biased  sorry.
No, I take it back  it _is_ biased  the geometry in R^2 makes that very clear.
Of course, as you now claim, you didn't care about bias.
But yet you were careful to avoid inflating the gaps!
>But your integer method is biased, and badly so.
Bottom line  both of the methods you proposed were biased. If you really intended that (which is very doubtful), you should have at least disclosed that fact.
quasi

