in reply to Re: list of random numbers with given avarage
in thread list of random numbers with given avarage

This could result in values outside the allowed values.

Example:

bottom = 0
top = 100
range = bottom - top = 100
desired average = 25
which would result in
sub f{rand(100) - 50 + 25}
which is equivalent to
sub f{rand(100) - 25}
As you can see, 25% percent of the time, you would get a result that was out of the allowed bounds.
  • Comment on Re: Re: list of random numbers with given avarage

Replies are listed 'Best First'.
Re: Re: Re: list of random numbers with given avarage
by belg4mit (Prior) on Mar 12, 2002 at 20:23 UTC
    Umm not exactly, I guess I didn't make myself clear. My proposed algorythm *does not* meet the same requirements, namely top and bottom. It instead provides what I imagine the original algorythm would most likely be used for which is providing "random" values centered around a given value (the average).

    UPDATE: Note this simpler method makes more sense for the physicists as well. The other algorythm produces many outliers which ought to be discarded in a real data set.

    Average=50, Range=10
    
    Average:        Avg - Rng/2:      Avg - Rng/2 + rnd(Rng):
    45----50----55  45----50----55    45----50----55
           *         *                 ????? ??????
    
    Since rnd can return anything between 0 (minimum) or Range (maximum) we get a full spread. It may also be interesting to note that this is equivalent to sub f{average+range/2-rnd(range)}

    --
    perl -pe "s/\b;([st])/'\1/mg"