Question

Generate 100 Poisson (λ = 2) random numbers using the Inverse transformation method, and then compare...

Generate 100 Poisson (λ = 2) random numbers using the Inverse transformation method, and then compare with the theoretical mean and variance.

please let me know the explanaiton with detail, and r code, If not, at least python

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Run below code rmin R:

(list=ls())


#### Lets find CDF i.e. F(X=x) for Poisson(m=2)
# Evaluating till X = 15 as P(X=x)is negligible after X=15
F_x=ppois(0:15,lambda = 2)
F_x


### Lets genarate 100 random numbers from U(0,1)
u=runif(100,min = 0,max = 1)

### Now create Poisson r.n. using its cdf and r.n. from U(0,1)
### If u belongs to ( F(x-1), F(x) ) then Poisson r.v. will be equal to x
X=c()
for(i in 1:100){
X=c(X,min(which(F_x>u[i])))
}

X
cat('Sample mean=', mean(X),'And theoretical mean=2')
cat('Sample variance=',var(X), 'And theoretical variance=2')

You will get below output> rm(list=ls ) Values num [1:16] 0.135 0.40G 100L num (1:100] 0.317 0.46 int (1:100] 2 3 2 2 2 > #### Lets find CDF i.e. F(X=

Add a comment
Know the answer?
Add Answer to:
Generate 100 Poisson (λ = 2) random numbers using the Inverse transformation method, and then compare...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT