# Difference between revisions of "Group Two: The Towne Family - Again, Class Activity"

Class Activity Team: Todd Swinson

Shuqi

Eleisha Jackson

1. Sketch the distribution $\displaystyle p_X(x)$

2. What is the distribution's mean and standard deviation? Mean:

$\displaystyle \text{Mean} = E(x)$

$\displaystyle E(x) = \int_0^2 xp(x) dx = \int_0^2 x\left(1 - \frac{x}{2}\right) dx = \frac{x^2}{2} - \frac{x^3}{6} \Big|_0^2 = \frac{2}{3}$

Standard Deviation:

$\displaystyle \text{Standard Deviation} = \sqrt{\text{Variance}}$

$\displaystyle \text{Variance} = \int_0^2 x^2p(x) dx - [E(x)]^2 = \left(\frac{x^3}{3} - \frac{x^4}{8}\right)\Big|_0^2 - [E(x)]^2 = \frac{6}{9} -\frac{4}{9} = \frac{2}{9}$

$\displaystyle \text{Standard Deviation} = \sqrt{\text{Variance}} = \sqrt{\frac{2}{9}}$

3. What is its cumulative distribution function (CDF)?

CDF = F(x)

$\displaystyle F(x) = x(1-\frac{x}{4}) \text{ for } 0

4. Write code or pseudocode for drawing random deviates from the distribution. (You may assume that you have a random generator for unifor (0,1).)

Code:


def getRandomDeviate():
p = random.random()
return -2*sqrt(1-p) + 2

def testRandomDeviateGenerator():
curset = []
for i in range(100000):
curset.append(getRandomDeviate())
figure()
h = hist(curset, 1000)
title('histogram of 100000 random deviates sampled for P_X(x)')


Graph of Random Deviates:

5. What is the approximate distribution of the sum S of N deviates drawn from $\displaystyle p_X(x)$ , where N >>1? The sum of S of N deviates can be approximated by a Normal by the Central Limit Theorem

So....

$\displaystyle p_S(.) \text{Normal}(\frac{2}{3}N, \frac{2}{9N} )$

6. You sum all 28, get a p-value for the sum under the null hypothesis which is the distribution from 5 with N = 28. You are basically computing a pvalue using the distribution form 5 as the null distribution