Skip to content
Prev 361847 / 398506 Next

better loop for simulation

use replicate:
+          prob.success <- 1 / mult.choice
+          answers <- (runif(n.questions) < prob.success)
+          return(sum(answers))
+  }
The decimal point is at the |
   0 | 0
   1 | 0000000000000
   2 | 000000000000000000000000000000000000000000000000000000000
   3 |
00000000000000000000000000000000000000000000000000000000000000000000+26
   4 |
00000000000000000000000000000000000000000000000000000000000000000000+116
   5 |
00000000000000000000000000000000000000000000000000000000000000000000+153
   6 |
00000000000000000000000000000000000000000000000000000000000000000000+142
   7 |
00000000000000000000000000000000000000000000000000000000000000000000+35
   8 | 00000000000000000000000000000000000000000000
   9 | 000000000000
  10 | 0


Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Sat, Jun 18, 2016 at 6:12 PM, Naresh Gurbuxani <
naresh_gurbuxani at hotmail.com> wrote:

            

  
  
Message-ID: <CAAxdm-4D0N4d640hV2TdX0evPjt5hzP+aEC46XMEHRzaeuTqkw@mail.gmail.com>
In-Reply-To: <CY1PR07MB25888BEDCE91D0116E2987E9FA280@CY1PR07MB2588.namprd07.prod.outlook.com>