ผลต่างระหว่างรุ่นของ "Probstat/week6 practice 1"

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
แถว 56: แถว 56:
  
 
=== Uniform distribution ===
 
=== Uniform distribution ===
 +
Let random variable '''X''' represent a real number chosen uniformly in the range 0 to 1.
 +
 +
1. Plot the histogram of '''X'''.  (Generate '''X''' for 10,000 times, use about 100 buckets.)
 +
 +
2. Estimate '''E[X]'''.
 +
 +
3. Estimate '''Var(X)'''.
  
 
=== Normal/Gaussian distribution ===
 
=== Normal/Gaussian distribution ===
  
 
=== Uniform distribution in 2D ===
 
=== Uniform distribution in 2D ===

รุ่นแก้ไขเมื่อ 01:14, 23 กันยายน 2557

This is part of probstat.

In this practice, we will try a few experiments that shows distributions of random variables with varying variances.

Variances and distribution

In each of the following experiments, you should find the expectation and the variance of the specified random variable. Then perform at least 10,000 experiments to generate the histogram of the distribution of the random variable.

Set 1: uniform distribution

1.1 We pick randomly an integer from the set {0,1,2,...,10}. Let X be the number that we picked. Find E[X], Var(X), and perform random experiments to plot X histogram.

Hint: for question 1.2 - 1.5, finding Var(X) 'indirectly' using the result from 1.1 might be an easier approach.

1.2 We pick randomly an integer from the set {0,1,2,...,10} for 2 times (with replacement). Let Y be the sum of the 2 numbers that we picked. Let X = Y/2. Find E[X], Var(X), and perform random experiments to plot X histogram.

1.3 We pick randomly an integer from the set {0,1,2,...,10} for 3 times (with replacement). Let Y be the sum of the 3 numbers that we picked. Let X = Y/3. Find E[X], Var(X), and perform random experiments to plot X histogram.

1.4 We pick randomly an integer from the set {0,1,2,...,10} for 5 times (with replacement). Let Y be the sum of the 5 numbers that we picked. Let X = Y/5. Find E[X], Var(X), and perform random experiments to plot X histogram.

1.5 We pick randomly an integer from the set {0,1,2,...,10} for 10 times (with replacement). Let Y be the sum of the 10 numbers that we picked. Let X = Y/10. Find E[X], Var(X), and perform random experiments to plot X histogram.

Set 2: +1, -1

2.1 We pick randomly an integer from the set {-1,+1}. Let X be the number that we picked. Find E[X], Var(X), and perform random experiments to plot X histogram.

2.2 We pick randomly an integer from the set {-1,+1} for 2 time (with replacement). Let Y be sum of 2 numbers that we picked. Let X = Y/2. Find E[X], Var(X), and perform random experiments to plot X histogram.

2.3 We pick randomly an integer from the set {-1,+1} for 5 time (with replacement). Let Y be sum of 5 numbers that we picked. Let X = Y/5. Find E[X], Var(X), and perform random experiments to plot X histogram.

2.4 We pick randomly an integer from the set {-1,+1} for 10 time (with replacement). Let Y be sum of 10 numbers that we picked. Let X = Y/10. Find E[X], Var(X), and perform random experiments to plot X histogram.

2.5 We pick randomly an integer from the set {-1,+1} for 20 time (with replacement). Let Y be sum of 20 numbers that we picked. Let X = Y/20. Find E[X], Var(X), and perform random experiments to plot X histogram.

Set 3: imbalance distribution

3.1 We pick two numbers 0 and 10 at random. The probability that we pick 0 is 0.9 and the probability that we pick 10 is 0.1. Let X be the number that we pick. Find E[X], Var(X), and perform random experiments to plot X histogram.

3.2 We pick two numbers 0 and 10 at random for 2 times (with replacement). For each trial, the probability that we pick 0 is 0.9 and the probability that we pick 10 is 0.1. Let Y be sum of the numbers that we pick. Let X = Y/2. Find E[X], Var(X), and perform random experiments to plot X histogram.

3.3 We pick two numbers 0 and 10 at random for 10 times (with replacement). For each trial, the probability that we pick 0 is 0.9 and the probability that we pick 10 is 0.1. Let Y be sum of the numbers that we pick. Let X = Y/10. Find E[X], Var(X), and perform random experiments to plot X histogram.

Experiments on continuous random variables

Don't be afraid of continuity!

In this practice, we will experiment on a few important continuous random variables (before we actually learn about it).

Generating random numbers under various distributions

In this practice we will generate uniform random variables and normally distributed random variables. The function/method for generating them in Python and Java is described below.

Python: Python's random package provide many random number generators.

  • random.random() - Return the next random floating point number in the range [0.0, 1.0).
  • random.gauss(mu,sigma) - Gaussian distribution. mu is the mean, and sigma is the standard deviation. In our experiment, we shall use mu = 0, sigma = 1.

Java: Use the Java Random class. You have to create an instance of the class, then call these methods:

  • nextDouble() - Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.
  • nextGaussian() - Returns the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence.

Uniform distribution

Let random variable X represent a real number chosen uniformly in the range 0 to 1.

1. Plot the histogram of X. (Generate X for 10,000 times, use about 100 buckets.)

2. Estimate E[X].

3. Estimate Var(X).

Normal/Gaussian distribution

Uniform distribution in 2D