English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Suppose I have an array of 8 numbers x(1)=.15, x(2)=.50, x(3)=.02 etc. where x(1) + x(2) + x(3) ... x(8) = 100%

I want to write a subroutine that generates random numbers 1-8 where the chance of a 1 is 15%, the chance of a 2 is 50%, the chance of a 3 is 2%, etc. - according to the percentages in my table.

I just want an idea how to do it, not the actual code.... thanx!

2007-10-24 02:30:13 · 1 answers · asked by I'm an Atheist 3 in Computers & Internet Programming & Design

That's right... it's a version of the Monte Carlo method.... THANK YOU!

2007-10-24 04:19:41 · update #1

1 answers

So a random number between 1 and 100
where 1 to 15 = 1
16 to 65 = 2
66 to 67 = 3
etc.

2007-10-24 02:40:42 · answer #1 · answered by AnalProgrammer 7 · 3 0

fedest.com, questions and answers