# Probability

Suppose we consider the cholesterol level of a person chosen at random from a certain age group, or the height of an adult female chosen at random, or the lifetime of a randomly chosen battery of a certain type. Such quantities are called **continuous random variables** because their values actually range over an interval of real numbers, although they might be measured or recorded only to the nearest integer. Random variable is usually denoted by X. We assume that probability that continuous variable will take ceratain value a equals 0, that is `P(X=a)=0`.

Every continuous random variable has a **probability density function (PDF)** f. Probability density function has following properties:

- `f(x)>=0` for all x, (probability must be negative).
- `int_(-oo)^(oo)f(x)dx=1`, (probabilities of all possible outcomes must add up to 1).

So, to calculate probability that random variable X lies in interval [a,b], we need to evaluate following integral: `P(a<=X<=b)=int_a^b f(x)dx`.

Example 1. Let `f(x)={(Ae^(-cx) if x>=0),(0 if x<0):}` .

Find constant A, so that f(x) is probability density function.

Let c=0.2. Find probability that X is less than 3, probability that X lies in interval [4,6] and probability that X greater then 7.

*Solution*.

Clearly, `f(x)>=0`, therefore we need to find such A that `int_(-oo)^(oo)f(x)dx=1` .

Note, that since `f(x)=0` for `x<0` then we change limits of integration to `0,oo` .

This integral is improper, so we use definition of improper integral:

`int_(-oo)^(oo)f(x)dx=int_0^(oo)Ae^(-cx)dx=Alim_(t->oo)int_0^te^(-cx)dx=-A/clim_(t->oo)e^(-cx)|_0^t=`

`=-A/clim_(t->oo)(e^(-ct)-1)=-A/c(-1)=A/c` .

This value must equal 1. therefore `A=c` .

`f(x)={(ce^(-cx) if x>=0),(0 if x<0):}` is probability density function of **exponentially distributed random variable**

If c=0.2 then `f(x)={(0.2e^(-0.2x) if x>=0),(0 if x<0):}`.

First of all note that there is no difference between `P(X<=3)` and `P(X<3)` , because `P(X=3)=0`: `P(X<=3)=P(X<3)+P(X=3)=P(X<3)+0=P(X<3)`.

`P(X<=3)=int_(-oo)^3 f(x)dx=int_0^3 0.2e^(-0.2x)dx=-e^(-0.2x)|_0^3=1-e^(-0.6)~~0.4512`.

`P(4<=X<=6)=int_4^6f(x)dx=int_4^6 0.2e^(-0.2x)dx=-e^(-0.2x)|_4^6=e^(-0.8)-e^(-1.2)~~`

`~~0.148135`.

`P(X>=7)=int_7^(oo)0.2e^(-0.2x)dx=0.2lim_(t->oo)int_7^te^(-0.2x)dx=-lim_(t->oo)e^(-cx)|_7^t=lim_(t->oo)(e^(-1.4)-e^(-ct))=`

`=e^(-1.4)~~0.2466`.

The **mean** of any probability density function is defined to be `mu=int_(-oo)^(oo)xf(x)dx`.

The expression for the mean resembles an integral we have seen before in the Moments and Centers of Mass note. If R is the region that lies under the graph of f, we know that x-coordinate of the centroid of R is `(int_(-oo)^(oo)xf(x)dx)/(int_(-oo)^(oo)f(x)dx)=(int_(-oo)^(oo)xf(x)dx)/(1)=int_(-oo)^(oo)xf(x)dx=mu`.

So a thin plate in the shape of R balances at a point on the vertical line `x=mu`.

Example 2. Find the mean of exponentially distributed random varible.

We know that exponentially distributed random variable has PDF `f(x)={(ce^(-cx) if x>=0),(0 if x<0):}`.

Therefore, `mu=int_(-oo)^(oo)xf(x)dx=int_0^(oo)xce^(-cx)dx=lim_(t->oo)int_0^txce^(-cx)dx`.

On this stage we use integration by parts: let `u=x` and `dv=ce^(-cx)dx` then `du=dx` and `v=int ce^(-cx)dx=-e^(-cx)` .

Now, we have `lim_(t->oo)int_0^t xce^(-cx)dx=lim_(t->oo)(x(-e^(-cx))|_0^t-int_0^t(-e^(-cx))dx)=lim_(t->oo)(-te^(-ct)-1/c e^(-cx)|_0^t)=`

`=lim_(t->oo)(-te^(-ct)-1/c e^(-ct)+1/c)=1/c`.

Therefore, `mu=1/c` and PDF can be rewritten as `f(x)={(1/mu e^(-x/mu) if x>=0),(0 if x<0):}`.