Difference between revisions of "Eleisha's Segment 17: The Towne Family - Again"

From Computational Statistics Course Wiki
Jump to navigation Jump to search
 
(8 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
1. Sketch the distribution <math>  p_X(x)</math>
 
1. Sketch the distribution <math>  p_X(x)</math>
 +
 +
[[File:Eleisha_Feb_24_PDF.png]]
  
 
2. What is the distribution's mean and standard deviation?
 
2. What is the distribution's mean and standard deviation?
Line 12: Line 14:
 
Standard Deviation:
 
Standard Deviation:
  
<math> \text{Standard Deviation} = \sqrt{Variance} </math>
+
<math> \text{Standard Deviation} = \sqrt{\text{Variance}} </math>
 +
 
 +
<math>\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} </math>
 +
 
 +
<math> \text{Standard Deviation} = \sqrt{\text{Variance}}  = \sqrt{\frac{2}{9}}</math>
 +
 
 +
3. What is its cumulative distribution function (CDF)?
 +
 
 +
CDF = F(x)
 +
 
 +
<math> F(x) = x(1-\frac{x}{4}) \text{ for } 0<x<2 \text{, 0 otherwise } </math>
 +
 
 +
[[File:Eleisha_Feb_24_CDF.png]]
 +
 
 +
 
 +
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).)
  
<math>\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) =  </math>
+
Code:
 +
<pre>
  
 +
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)')
 +
</pre>
  
3. What is its cumulative distribution function (CDF)?
+
Graph of Random Deviates:
 +
[[File:group2_rand_deviates_hist.png]]
 +
 
 +
5. What is the approximate distribution of the sum S of N deviates drawn from <math> p_X(x)</math>, where N >>1?
 +
The sum of S of N deviates can be approximated by a Normal by the Central Limit Theorem
 +
<math> p_S(.) Normal(\frac{2}{3}N, \frac{2}{9N} ) </math>

Latest revision as of 15:39, 24 February 2014

Class Activity

1. Sketch the distribution Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle p_X(x)}

Eleisha Feb 24 PDF.png

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

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \text{Mean} = E(x) }

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\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:

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \text{Standard Deviation} = \sqrt{\text{Variance}} }

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\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} }

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \text{Standard Deviation} = \sqrt{\text{Variance}} = \sqrt{\frac{2}{9}}}

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

CDF = F(x)

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle F(x) = x(1-\frac{x}{4}) \text{ for } 0<x<2 \text{, 0 otherwise } }

Eleisha Feb 24 CDF.png


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: Group2 rand deviates hist.png

5. What is the approximate distribution of the sum S of N deviates drawn from Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\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 Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle p_S(.) Normal(\frac{2}{3}N, \frac{2}{9N} ) }