Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
A vast area which includes generating results from computer models.
3
votes
Accepted
Clinical trials simple randomization scheme simulation
You could write a for loop:
# Option 1: `naive` simulation
N <- 1000
n_out <- 0
for(i in 1:N){
sum1 <- sum(rbinom(100, 1, 0.5))
outside <- abs(sum1 - 50) > 5
n_out <- n_out + outside
}
proportion … This can be written sunccinctly in one single line:
# Option 2: better simulation
N <- 1000
n_out <- sum(abs(rbinom(N, 100, 0.5) - 50) > 5)
proportion <- n_out/N
Finally, denote by $X$ the random variable …