Is there a sort of random number generator like this (SEE DETAILS)
Favorites|Homepage
Subscriptions | sitemap
HOME > Mathematics > Is there a sort of random number generator like this (SEE DETAILS)

Is there a sort of random number generator like this (SEE DETAILS)

[From: ] [author: ] [Date: 11-05-05] [Hit: ]
=COUNTIF(A3:A6,assuming you have the RAND function formula in cells A3, A4, A5 and A6.Every time you press F9, the sheet will recalculate and give different results.......
Is there a random number generator that can generate random numbers form a certain range (ex. 0-1), show the results of how many of each number occured in each trial. and then organize it into a table?

For example, one trial is generating random numbers from 0-2 4 times and store the results into a table column like this:

Results
0 l 1 l 2 (number generated)
2 l 1 l 1 (number of times each number was randomly generated for 1 trial)

Then I want the trial to repeat 100 times and store the results for each trial.

-
You can try doing it on a spreadsheet using spreadsheet formulas.

For example, to do this on Excel 2007:

1.) enter the formula =INT(RAND()*(3-0)+0) into a cell
2.) then copy this formula and paste it to 3 more cells

Now, to count the frequency of occurrence of the numbers 0-2, use the COUNTIF function like this:

=COUNTIF(A3:A6,0) for 0
=COUNTIF(A3:A6,1) for 1
=COUNTIF(A3:A6,2) for 2

assuming you have the RAND function formula in cells A3, A4, A5 and A6.

Every time you press F9, the sheet will recalculate and give different results.
If you are using a different version of Excel, the syntax for the RAND function may be a little different; check the documentation.

To repeat it in several number of trials, you might want to do it using macro.

But the easiest way is to copy the random number generator formulas in 100 columns so that you can have a simulation of 100 trials.

-
Random number generators do what the name implies, give you sequences of random numbers. It's up to you to write the program to collect them into tables and print results.

What you propose is pretty simple. Probably less than 10 lines of code in Matlab.

Edit: I just mentioned Matlab since you gave no clue about your programming environment. But certainly it has a random number generator built in. If you don't have a programming environment, then any talk of random number generators makes no sense.

Most built-in random number generators return floating-point values from 0 to just less than 1. If you can guarantee the max value is never 1, then you can use round(0.5 + n * random_number_generator) to generate uniform random integers from 0 to n.

So write a loop to generate them and count them, to build your table.
1
keywords: Is,of,random,SEE,this,like,DETAILS,there,sort,number,generator,Is there a sort of random number generator like this (SEE DETAILS)
New
Hot
© 2008-2010 http://www.science-mathematics.com . Program by zplan cms. Theme by wukong .