Purchase Solution

Polya urn simulation via R

Not what you're looking for?

Ask Custom Question

I need help in two probability problems using R program. Thanks so much!
1. Simulation of an expectation. Design a simulation exercise in R to approximate the value of E ( X^X)
when X has a U [0,1] distribution. Plot the value of the approximation as the sample size goes from 1 to
10,000. Use the Notebook feature in RStudio to create an HTML file for your answer.

2. Simulation of a Polya Urn. Put a = 10 white balls and b = 20 blue balls in an urn. Then, randomly draw
a ball from the urn, and replace it along with another ball of the same color, repeat.
a) Write an R program to simulate Rn, the proportion of white balls in the urn after n draws from the urn,
for any integer n.
b) Plot the histogram of Rn for n = 1,000.
c) Simulate Rn 10,000 times.
d) Overlay the histogram with a line graph of the appropriate limiting distribution. Use the Notebook
feature in RStudio to create an HTML file for your answer.

Purchase this Solution

Solution Summary

The solution provides the full code for both questions, with an explanation of what the key components mean.

Solution Preview

1. The code is given below. We simply sample from a uniform with the given sample size to estimate E(X^X). The last line should give you the plot you need.

means <- rep(NA, 10000)
for (sample_size in 1:10000) {
x <- runif(sample_size)
means[sample_size] <- mean(x^x)
}
plot(means)

2. Below we have the R ...

Purchase this Solution


Free BrainMass Quizzes
Solving quadratic inequalities

This quiz test you on how well you are familiar with solving quadratic inequalities.

Probability Quiz

Some questions on probability

Know Your Linear Equations

Each question is a choice-summary multiple choice question that will present you with a linear equation and then make 4 statements about that equation. You must determine which of the 4 statements are true (if any) in regards to the equation.

Geometry - Real Life Application Problems

Understanding of how geometry applies to in real-world contexts

Multiplying Complex Numbers

This is a short quiz to check your understanding of multiplication of complex numbers in rectangular form.