Displaying 1 result from an estimated 1 matches for "total_frequency".
2010 Jun 23
1
Generation of binomial numbers using a loop
...30, 25)
no_trials = c(10, 8, 6, 4, 2)
freq1 = rbinom(frequency[1], no_trials[1], prob[1])
freq2 = rbinom(frequency[2], no_trials[2], prob[2])
freq3 = rbinom(frequency[3], no_trials[3], prob[3])
freq4 = rbinom(frequency[4], no_trials[4], prob[4])
freq5 = rbinom(frequency[5], no_trials[5], prob[5])
total_frequency = c(freq1, freq2, freq3, freq4, freq5)
total_frequency = as.numeric(lapply(total_frequency, function(x){replace(x, x == 0, 1)}))
This helps me to generate (sum(frequency) = 275) non zero binomial numbers as
total_frequency
[1] 1 1 1 2 1 1 1 2 1 1 1 1 1 1 3 2 1 1 1 1 1 1 1 1 1 3 1 1 2 1 3 1 1 1...