PC Review


Reply
Thread Tools Rate Thread

Biased Number Generation?

 
 
plh
Guest
Posts: n/a
 
      19th Aug 2009
Hi Gurus,
What I want to do is similar to the use of the Rnd() function but I want to bias
the results. In my case I am obtaining numbers from 1 to 4 using
Int((uB - lB + 1) * Rnd + lB)
Where uB = 4 and lB = 1, but I want to skew the outcome so that 1 is more
probable that 2 which is more probable than 3 etc., with the probability values
yet to be determined.
Thank You,
-plh


--
Where are we going and why am I in this HAND BASKET??
 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      19th Aug 2009
First generate a value between 1 and 10. Then map it to an output as follows:

1 1
2 1
3 1
4 1
5 2
6 2
7 2
8 3
9 3
10 4

Clearly you will make more 1s than 2s.
more 2s than 3s
more 3s than 4s

You can modify the table size and contents to simulate any arbitrary
distrbution.
--
Gary''s Student - gsnu200901


"plh" wrote:

> Hi Gurus,
> What I want to do is similar to the use of the Rnd() function but I want to bias
> the results. In my case I am obtaining numbers from 1 to 4 using
> Int((uB - lB + 1) * Rnd + lB)
> Where uB = 4 and lB = 1, but I want to skew the outcome so that 1 is more
> probable that 2 which is more probable than 3 etc., with the probability values
> yet to be determined.
> Thank You,
> -plh
>
>
> --
> Where are we going and why am I in this HAND BASKET??
>

 
Reply With Quote
 
Bernard Liengme
Guest
Posts: n/a
 
      19th Aug 2009
In A11 I entered the numbers 10, 5, 2, 1 representing the weighting for
integers 1,2,3,4.
Thus I want 1 to be 10 times more likely than 4, etc
In A3 I entered =RANDBETWEEN(1,SUM($A$!:$D$1)
In B3 I used the formula
=IF(A4<=$A$1,1,IF(A4<=SUM($A$1:$B$1),2,IF(A4<=SUM($A$1:$C$1),3,4)))
I copied these two down to row 5003 to get 5000 random numbers
Note that RANDBETWEEN need the Analysis Toolpac in pre-2007 versions of
Excel


I used the Frequency function to find I had this distribution
1 2827 10.66792453
2 1362 5.139622642
3 546 2.060377358
4 265 1

So I have 2827 ones and one is 10.7 more frequent than 4
Hit F9 and I get
1 2855 10.93869732
2 1325 5.076628352
3 559 2.141762452
4 261 1

and so on
Any help?
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email


"plh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Gurus,
> What I want to do is similar to the use of the Rnd() function but I want
> to bias
> the results. In my case I am obtaining numbers from 1 to 4 using
> Int((uB - lB + 1) * Rnd + lB)
> Where uB = 4 and lB = 1, but I want to skew the outcome so that 1 is more
> probable that 2 which is more probable than 3 etc., with the probability
> values
> yet to be determined.
> Thank You,
> -plh
>
>
> --
> Where are we going and why am I in this HAND BASKET??



 
Reply With Quote
 
Bernd P
Guest
Posts: n/a
 
      19th Aug 2009
Hello,

I suggest to take my UDF redw or RandHistoGrm:
http://sulprobil.com/html/distributions.html

It should be exactly what you are looking for...

Regards,
Bernd
 
Reply With Quote
 
plh
Guest
Posts: n/a
 
      30th Aug 2009
Thank You gsnu200901, Bernard Li and Bernd P for your replies.
I used something very much like gsnu200901's method, but with 1-100, which lends
itself to dividing the % values a little finer.
-plh

In article <0CC5388F-B760-496F-BF4D-(E-Mail Removed)>,
=?Utf-8?B?R2FyeScncyBTdHVkZW50?= says...
>
>First generate a value between 1 and 10. Then map it to an output as follows:
>
>1 1
>2 1
>3 1
>4 1
>5 2
>6 2
>7 2
>8 3
>9 3
>10 4
>
>Clearly you will make more 1s than 2s.
>more 2s than 3s
>more 3s than 4s
>
>You can modify the table size and contents to simulate any arbitrary
>distrbution.
>--
>Gary''s Student - gsnu200901
>
>
>"plh" wrote:
>
>> Hi Gurus,
>>What I want to do is similar to the use of the Rnd() function but I want to bias
>> the results. In my case I am obtaining numbers from 1 to 4 using
>> Int((uB - lB + 1) * Rnd + lB)
>> Where uB = 4 and lB = 1, but I want to skew the outcome so that 1 is more
>>probable that 2 which is more probable than 3 etc., with the probability values
>> yet to be determined.
>> Thank You,
>> -plh
>>
>>
>> --
>> Where are we going and why am I in this HAND BASKET??
>>



--
Where are we going and why am I in this HAND BASKET??
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic math Q: how do I make a number-generation function that is biased toward a specified numeric value Ken Fine Microsoft C# .NET 13 26th Aug 2007 01:03 AM
Number Generation =?Utf-8?B?UmhvbmRh?= Microsoft Access 1 9th May 2005 08:58 PM
I need help with random number generation =?Utf-8?B?RGF2aWQgU3RvZGRhcmQ=?= Microsoft Excel Worksheet Functions 10 28th Mar 2005 07:06 AM
Re: Random Number Generation Tushar Mehta Microsoft Excel Worksheet Functions 0 29th Jul 2004 05:03 PM
Number Generation Chrisfpe Microsoft Access Forms 2 6th Aug 2003 08:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:25 AM.