Hello! I am in desperate need of help. Only parts a,c,and d are needed. Please p
ID: 3227159 • Letter: H
Question
Hello! I am in desperate need of help. Only parts a,c,and d are needed. Please please help me out of this one! Much thanks in advance!!
This project requires writing computer code to generate random variables of various kinds and measure their probability distributions. 1. Generate a sequence of each of the following types of random variables; each sequence should be at least 10,000 points long. (a) A binomial random variable. Let the number of Bernoulli trials be n 12 Recall that the binomial random variable is defined as the number of 1s in n trials for a Bernoulli (binary) random variable. Let the parameter p in the Bernoulli trials be p 0.5109 COMPUTER PROJECTS (b) A Poisson random variable as a limiting case of the binomial random variable with p 0.0125 or less and n 80 or more while maintaining mp (c) A type 1 geometric random variable with parameter p 0.09. (d) A (continuous) uniform random variable in the range [-2,5].Explanation / Answer
Let's use R in order to generate the random variable distribution.
a) Binomial random variaable with n = 12 and p = 0.5109
> set.seed(124)
> binom <- rbinom(15000,12,0.5109)
This generates 15000 random values with the specified parameters of binomial distribution.
You can check for few of them as -
> binom[1:10]
The output will show you such 10 values generated as -
[1] 9 7 6 7 7 7 6 6 4 7
We can get the mean and variance of this distribution using following commands -
> mean(binom)
[1] 6.126333
> sd(binom)
[1] 1.736138
----------------------------------------------------
c)
Geometric distribution with parameter p=0.09
> geom <- rgeom(15000,0.05)
Then you can look at first 10 values using
> geom[1:10]
The output will be -
[1] 24 32 8 4 5 5 53 12 5 2
Again the mean and standard deviation is obtained as -
> mean(geom)
[1] 19.3198
> sd(geom)
[1] 19.70581
---------------------------------------------------------------------
d) uniform distribution in [-2,5]
> unif <- runif(15000,-2,5)
And then the first 10 observations can be recorded as -
> unif[1:10]
[1] -1.0389073 0.9418287 2.6266789 1.4080027 2.8961932
[6] -1.5197910 0.8426740 -0.1168590 -0.3473164 3.3771192
Then the mean and standard deviations are obtained as -
> mean(unif)
[1] 1.517832
> sd(unif)
[1] 2.023985
------------------------------------------------------------
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.