Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I don't understand maths very well so sorry for my newbie question.

Imagine I have a bank and clients of this bank. Clients arrive following a uniform distribution with $3.5$ mean and $1.3$ standard deviation.

How can I calculate a random number with this data?

I know that $f(x) = \frac{1}{(b-a)}$ on the interval $[a,b]$. So

$$P(c\leq X \leq d) = \frac{(d-c)}{(b-a)}$$

In my example, $a$ and $b$ will be generated using a random generator but I don't understand how I can generate a random number following a uniform distribution with my mean and standard deviation.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

First will come the pretty complete theory. Then we look at your particular situation.

Theory: We need an expression for the variance of $X$. The variance is $E(X^2)-(E(X))^2$. For $E(X^2)$, we need to calculate $$\int_a^b \frac{x^2}{b-a}\,dx,$$ which is $\frac{b^3-a^3}{3(b-a)}$. This simplifies to $\frac{b^2+ab+a^2}{3}$.

I imagine that you know that $E(X)=\frac{b+a}{2}$. One can do this by integration, but it is clear by symmetry that the mean is halfway between $a$ and $b$.

So we know that the variance is $\frac{b^2+ab+a^2}{3}-\frac{(b+a)^2}{4}$. Bring to a common denominator, simplify. We get that $$\text{Var}(X)=\frac{(b-a)^2}{12} \tag{$\ast$}.$$ More simply, you can search under uniform distribution, say on Wikipedia. They will have the expression $(\ast)$ for the variance of $X$.

Your problem: We know that $\frac{b+a}{2}=3.5$. We also know that the standard deviation of $X$ is $1.3$, so the variance is $(1.3)^2=1.69$.

So, by $(\ast)$, $\frac{(b-a)^2}{12}=1.69$, and therefore $b-a=\sqrt{(12)(1.69)}\approx 4.5033$. We also know that $b+a=(2)(3.5)=7$. Now that we know $b-a$ and $b+a$, it is easy to find $a$ and $b$.

For your simulation, presumably you are starting from a random number generator that generates numbers that are more or less uniformly distributed on $[0,1)$. If $U$ represents the output of such a generator, we simulate $X$ by using $a+(b-a)U$. And we now know $a$ and $b$.

Added If you want a general formula instead of a procedure, let $\mu=\frac{a+b}{2}$ be the mean, and $\sigma=\frac{b-a}{\sqrt{12}}=\frac{b-a}{2\sqrt{3}}$ be the standard deviation. Then $\frac{b-a}{2}=\sqrt{3}\,\sigma$. We get $a=\frac{b+a}{2}-\frac{b-a}{2}=\mu-\sqrt{3}\,\sigma$. It follows that we can take $$X=\mu-\sqrt{3}\,\sigma + (2\sqrt{3}\,\sigma) U=\mu+(\sqrt{3}\,\sigma)(2U-1).$$

share|improve this answer
    
Thanks for the great explanation. So given my mean of $3.5$ and sdt of $1,3$ and $U$ of $0,2$, $a$ would be $1,2483$, $b$ would be $5,7516$ and $X=2,14896$? –  Favolas May 3 '12 at 8:58
    
@Favolas: I checked your calculation above. Agree. –  André Nicolas May 3 '12 at 13:00
    
Thanks. Just one more question. Could this be done $X = mean - 0.5 + sdt * sqrt(12) * U$ ? –  Favolas May 3 '12 at 14:27
    
I will add a formula of this type (but different) to the post. –  André Nicolas May 3 '12 at 14:32
    
Thanks. Don't quite understand the $Subtract$ part but thanks for the last formula. Comparing yours with mine give quite different results. Many many thanks –  Favolas May 3 '12 at 15:21

Let $X$ be a uniformly distributed continuous random variable with mean $\mu$ and standard deviation $\sigma$. Then $$ X = \mu + 2 \sqrt{3} \sigma \left( U - \frac{1}{2} \right) $$ where $U$ is a random variables uniformly distributed on a unit interval. Indeed: $$ \mathbb{E}(X) = \mu + \sqrt{3} \sigma \mathbb{E}(2U-1) = \mu $$ $$ \mathbb{Var}(X) = (2 \sqrt{3} \sigma)^2 \mathbb{Var}(U-1/2) = 12 \sigma^2 \mathbb{Var}(U) = \sigma^2 $$ and, assuming both $x_1$ and $x_2$ in the domain of $X$, $$ \begin{eqnarray} \mathbb{P}( x_1 < X \leqslant x_2) &=& \mathbb{P}\left( x_1 < \mu + 2 \sqrt{3} \sigma \left( U - \frac{1}{2} \right) \leqslant x_2\right) \\ &=& \mathbb{P}\left( \frac{1}{2}+\frac{x_1 - \mu}{2 \sqrt{3} \sigma} < U \leqslant \frac{1}{2} + \frac{x_2 - \mu}{2 \sqrt{3} \sigma} \right) \\ &=& x_2-x_1 \end{eqnarray} $$

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.