Two Plus Two Newer Archives  

Go Back   Two Plus Two Newer Archives > General Gambling > Probability

Reply
 
Thread Tools Display Modes
  #1  
Old 11-17-2007, 02:15 AM
Ganjasaurus Rex Ganjasaurus Rex is offline
Senior Member
 
Join Date: Sep 2007
Posts: 336
Default Looking for event-based random number generator

Sorry if this is the wrong forum. Wasn't sure where to put it.

Anyway, i'm looking for a random number generator that you can pre-program in the mean, SD, range, etc of n numbers. So in other words, let's say i want to generate 100 random numbers but want to make sure that the final mean and SD are predetermined. Is there such a program?

TIA
Reply With Quote
  #2  
Old 11-17-2007, 03:38 AM
RustyBrooks RustyBrooks is offline
Senior Member
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 1,380
Default Re: Looking for event-based random number generator

This sparked a small memory in me and I did a quick investigation and it seems to hold.

You can actually generate a series of random numbers that are normally distributed by adding together 2 numbers that are randomly generated by a linear distribution. I remembered this because when you roll 2 dice, the sum of the dice is a standard distribution.

You can adjust to scale to the desired mean/standard deviation.

So, if you know any kind of programming language, go through a loop 100 times and do this:

n1 = rand()*std*2.45
n2 = rand()*std*2.45
num = mean + n1 + n2 - std*2.45

Why 2.45? I don't know. But it works.

I wrote a quick program for it. I could probably throw it up on the web if you're interested.
Reply With Quote
  #3  
Old 11-17-2007, 03:54 AM
jukofyork jukofyork is offline
Senior Member
 
Join Date: Sep 2004
Location: Leeds, UK.
Posts: 2,551
Default Re: Looking for event-based random number generator

[ QUOTE ]
This sparked a small memory in me and I did a quick investigation and it seems to hold.

You can actually generate a series of random numbers that are normally distributed by adding together 2 numbers that are randomly generated by a linear distribution. I remembered this because when you roll 2 dice, the sum of the dice is a standard distribution.

You can adjust to scale to the desired mean/standard deviation.

So, if you know any kind of programming language, go through a loop 100 times and do this:

n1 = rand()*std*2.45
n2 = rand()*std*2.45
num = mean + n1 + n2 - std*2.45

Why 2.45? I don't know. But it works.

I wrote a quick program for it. I could probably throw it up on the web if you're interested.

[/ QUOTE ]
I thought when I first read his post that he wanted to generate Gaussian random numbers too, but I think he wants to generate sequences that have an exact mean and standard deviation (eg: generate 10 random numbers that have a mean of -2.8 and a std of 1.5).

Juk [img]/images/graemlins/smile.gif[/img]
Reply With Quote
  #4  
Old 11-17-2007, 04:05 AM
Ganjasaurus Rex Ganjasaurus Rex is offline
Senior Member
 
Join Date: Sep 2007
Posts: 336
Default Re: Looking for event-based random number generator

[ QUOTE ]
[ QUOTE ]
This sparked a small memory in me and I did a quick investigation and it seems to hold.

You can actually generate a series of random numbers that are normally distributed by adding together 2 numbers that are randomly generated by a linear distribution. I remembered this because when you roll 2 dice, the sum of the dice is a standard distribution.

You can adjust to scale to the desired mean/standard deviation.

So, if you know any kind of programming language, go through a loop 100 times and do this:

n1 = rand()*std*2.45
n2 = rand()*std*2.45
num = mean + n1 + n2 - std*2.45

Why 2.45? I don't know. But it works.

I wrote a quick program for it. I could probably throw it up on the web if you're interested.

[/ QUOTE ]
I thought when I first read his post that he wanted to generate Gaussian random numbers too, but I think he wants to generate sequences that have an exact mean and standard deviation (eg: generate 10 random numbers that have a mean of -2.8 and a std of 1.5).

Juk [img]/images/graemlins/smile.gif[/img]

[/ QUOTE ]
I want to make a gaussian curve of random numbers with a predetermined mean and SD. Does Rusty's program do that?
Reply With Quote
  #5  
Old 11-17-2007, 04:14 AM
RustyBrooks RustyBrooks is offline
Senior Member
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 1,380
Default Re: Looking for event-based random number generator

What I have will generate a sequence of numbers that have a given mean and standard distribution.
Reply With Quote
  #6  
Old 11-17-2007, 04:15 AM
RustyBrooks RustyBrooks is offline
Senior Member
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 1,380
Default Re: Looking for event-based random number generator

(normal distribution = gaussian distribution, so I'm not entirely sure what you mean)
Reply With Quote
  #7  
Old 11-17-2007, 04:25 AM
jukofyork jukofyork is offline
Senior Member
 
Join Date: Sep 2004
Location: Leeds, UK.
Posts: 2,551
Default Re: Looking for event-based random number generator

[ QUOTE ]
[ QUOTE ]
[ QUOTE ]
This sparked a small memory in me and I did a quick investigation and it seems to hold.

You can actually generate a series of random numbers that are normally distributed by adding together 2 numbers that are randomly generated by a linear distribution. I remembered this because when you roll 2 dice, the sum of the dice is a standard distribution.

You can adjust to scale to the desired mean/standard deviation.

So, if you know any kind of programming language, go through a loop 100 times and do this:

n1 = rand()*std*2.45
n2 = rand()*std*2.45
num = mean + n1 + n2 - std*2.45

Why 2.45? I don't know. But it works.

I wrote a quick program for it. I could probably throw it up on the web if you're interested.

[/ QUOTE ]
I thought when I first read his post that he wanted to generate Gaussian random numbers too, but I think he wants to generate sequences that have an exact mean and standard deviation (eg: generate 10 random numbers that have a mean of -2.8 and a std of 1.5).

Juk [img]/images/graemlins/smile.gif[/img]

[/ QUOTE ]
I want to make a gaussian curve of random numbers with a predetermined mean and SD. Does Rusty's program do that?

[/ QUOTE ]
It will sample them from the Gaussian distribution and if you take enough samples (millions) the sampled mean/std will eventually approach the true mean/std you asked for, but it can't be used to select a fixed length sequence that gives an exact mean and std each time.

The only method I can think of is to just generate lots and lots of fixed length sequences (using a suitable Gaussian RNG generator) and discard the ones which don't have the exact mean and std you are looking for. If the ordering matters then you can always permute the order of (and reuse) the sequences using a shuffling algorithm (eg: Knuth Shuffle) as the mean and std won't be affected by order.

This link and the GSL source-code might also be helpful.

Juk [img]/images/graemlins/smile.gif[/img]
Reply With Quote
  #8  
Old 11-17-2007, 04:28 AM
jukofyork jukofyork is offline
Senior Member
 
Join Date: Sep 2004
Location: Leeds, UK.
Posts: 2,551
Default Re: Looking for event-based random number generator

[ QUOTE ]
(normal distribution = gaussian distribution, so I'm not entirely sure what you mean)

[/ QUOTE ]
Unless I've misread his OP, I think he wants to generate fixed length sequences which have a certain mean/std (as opposed to sampling from the Gaussian distribution).

Juk [img]/images/graemlins/smile.gif[/img]
Reply With Quote
  #9  
Old 11-17-2007, 04:33 AM
RustyBrooks RustyBrooks is offline
Senior Member
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 1,380
Default Re: Looking for event-based random number generator

Exact? No. But for 100-length sequences it's OK. No 100-sized sample from a general population with a given mean and standard deviation will have that exact mean and standard deviation anyway. OK, so here are some samples from mean=50, std=25. When n=1000 the means are all within about 1, and std is within .4

mean == 46.1312, std == 25.0674
mean == 47.3159, std == 24.4849
mean == 46.4967, std == 25.8444
mean == 44.4332, std == 26.5974
mean == 48.8557, std == 26.0069
mean == 47.8602, std == 25.5480
mean == 52.0704, std == 27.5603
mean == 49.9019, std == 27.4975
mean == 52.4116, std == 24.7947
mean == 48.9171, std == 24.2495
mean == 50.5276, std == 22.1211
mean == 52.2813, std == 27.1429
mean == 49.0307, std == 22.4335
mean == 51.0344, std == 27.2197
mean == 50.5114, std == 24.4022
mean == 51.7506, std == 26.0787
mean == 48.8765, std == 27.6355
mean == 46.4424, std == 23.5208
mean == 44.5342, std == 24.2434
mean == 42.9070, std == 24.9680
Reply With Quote
  #10  
Old 11-17-2007, 04:34 AM
RustyBrooks RustyBrooks is offline
Senior Member
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 1,380
Default Re: Looking for event-based random number generator

There's no way to get an exact mean/std in this way without doing what you suggested and rigorously weeding. I doubt that's what he wants though.
Reply With Quote
Reply

Thread Tools
Display Modes

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

Forum Jump


All times are GMT -4. The time now is 10:50 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.