1
$\begingroup$

I am attempting to find the expected value and variance of the random variable $X$ analytically (in addition to a decimal answer). $X$ is the random variable expression(100)[-1] where expression is defined by:

def meander(n):
       x = [0]
       for t in range(n):
           x.append(x[-1] + 3*random.random())
       return x

For those that do not understand the Python, $X$ is essentially the sum of a sequence of $100$ values with value of 3*random.random(), where random.random() is uniformly distributed on $[0,1)$.

I am almost certain that I will need to apply the concepts of: $$\text{mean}\left(\bar{X}\right)=E\left(\frac{1}{n}\left(X_1+X_2+...+X_n\right)\right)=E\left(X\right)$$ $$\text{and}$$ $$\text{var}\left(\bar{X}\right)=var\left(\frac{1}{n}\left(X_1+X_2+...+X_n\right)\right)=\frac{1}{n}\text{var}\left(X\right)$$ $$\text{where, }\bar{X}=\frac{1}{n}\left(X_1+X_2+...+X_n\right)$$

I am having difficulty understand how I should be plugging in this equation and representing it symbolically, let alone calculating it. I created a simulation in order to better understand the distribution of the data (in addition to getting an estimate of the expected value) and it seems to be a Gaussian distribution (histogram of distribution after 100,000 trials). The simulation suggests an estimated expected value of $150.038527551$.

These solutions will culminate in the usage of the Central Limit Theorem in finding an analytical expression that approximates the pdf of $X$.

Any guidance or help to point me in the right direction would be very much appreciated!

$\endgroup$

2 Answers 2

2
$\begingroup$

So, your random variable is $$ X = 3X_1+\dots+3X_{100} = \sum_{k=1}^n 3X_k $$ with $n=100$, where $X_1,\dots, X_n$ are independent, identically distributed random variables that are uniform in $[0,1)$. In particular, $\mathbb{E}\left[ X_k \right] = \frac{1}{2}$ and $\operatorname{var} X_k = \frac{1}{12}$ for every $1\leq k\leq n$.

By linearity of expectation, you get $$ \mathbb{E}[X] = \mathbb{E}\left[ \sum_{k=1}^n 3X_k \right] = \sum_{k=1}^n 3\mathbb{E}\left[ X_k \right] =\sum_{k=1}^n 3\cdot \frac{1}{2} = n\cdot \frac{3}{2} = 150. $$ (this does not rely on the fact that the $X_k$'s are independent, only on the fact that they all have a well-defined expectation).

By properties of variance (detailed below), crucially relying on the fact that the $X_k$'s are independent, you obtain $$ \operatorname{var}(X) = \operatorname{var}\left( \sum_{k=1}^n 3X_k \right) = \sum_{k=1}^n \operatorname{var}(3 X_k) = \sum_{k=1}^n 9\operatorname{var} X_k =\sum_{k=1}^n 9\cdot \frac{1}{12} = n\cdot \frac{3}{4} = 75 $$ where we used first the fact that "the variance of the sum of (pairwise) independent random variables is the sum of their variances",* and then that $ \operatorname{var}(aY) = a^2 \operatorname{var}(Y)$ for any real number $a$.

(*) Provided the variances are well-defined, i.e. the random variables are in $L^2$.

$\endgroup$
0
$\begingroup$

Clement C has already explained the theoritical part. Here is my programmatic explanation.

Let the variables be $X = \sum_1^k x_k$ where $x_k$ is $U(0,1)$

You can calculate mean & variance in two ways : One is straight forward. Compute X and use following formulae. $$mean(X) = \sum_1^nX$$ $$var(X) = \sum_1^nX^2/n -mean(x)^2 $$

However since x is independent, we can use following formulate $$ mean (X) = mean(\sum_1^k x_k) = \sum_1^k(mean(x_k)) $$ $$ var(X) = var(\sum_1^k x_k) = \sum_1^k(var(x_k)) $$

import random import math def meander(n):

x is 2-D array of values

x[i][j]; j corresponds to k & i is the ith sample

    x = [ [ 3*random.random() for i in range(0,100)] for i in range(0,n)]

evaluate X variables by sum over j

    X = [ sum(i) for i in x]

calculate mean & variance of X

    X_ = sum(X)/n
    var_X_ =  sum([i*i for i in X])/n - X_*X_

by formulae

calculate mean of each X_k ; i.e sum over i

    mean_xk = []
    var_xk = []
    for i in range(0,100):
            s = 0
            s_2 = 0
            for j in range(0,n):
                    s = s+x[j][i]
                    s_2 = s_2+x[j][i]*x[j][i]
            mean_k = s/n
            mean_xk.append(mean_k)
            sum_of_square = s_2
            var_xk.append( sum_of_square/n - mean_k*mean_k)

    formula_X_ = sum(mean_xk)
    formula_var_X_ = sum(var_xk)

    return [X_, var_X_, formula_X_, formula_var_X_]

print meander(100000)

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .