• Nem Talált Eredményt

Expected value of a function of a continu- continu-ous random variable

In document PROBABILITY THEORY WITH SIMULATIONS (Pldal 164-171)

We leared in Chapter 17 of Part II that if we make N experiments for a discrete random variable X, and we substitute the experimental results X1,X2, . . . ,XN into the function y= t(x), and we consider the values t(X1),t(X2), . . . ,t(XN), then their average is is close to the expected value oft(X):

t(X1) +t(X2) +. . .+t(XN)

N ≈E(t(X))

The same stabilization rule is true in the case of a continuous random variable. Let X be a continuous random variable, and t(x) a continuous function. The expected value of the random variablet(X)is calculated by the integral:

E(t(X)) = Z

−∞t(x)f(x)dx

Motivation of the declared formula. We give here some motivation of the declared formula of the expected value oft(X). For this purpose, let us take a continuous random variable X, and a continuous functiont(x), and and let X1,X2, . . . ,XN be the experimental results forX.

We will show that the average of the function values of the experimental results is close to the above integral:

t(X1) +X2+. . .+t(XN)

N ≈

Z

−∞

t(x)f(x)dx

In order to show this, we choose the fixed points . . . ,yi,yi+1, . . . on the real line so that all the differences ∆yi=yi+1−yi are small. Then we introduce a discrete random variable, so that the value ofY is derived from the value of X by rounding down to the closestyi value which is on the left side ofX, that is,

Y =yi if and only if yi≤X <yi+1

Applying the rounding operation to each experimental result, we get the values Y1,Y2, . . . ,YN

161

162 PROBABILITY THEORY WITH SIMULATIONS

Since all the differences ∆yi=yi+1−yi are small, and the function t(x) is continuous, we have that

t(X1) +t(X2) +. . .+t(XN)

N ≈ t(Y1) +t(Y2) +. . .+t(YN)

N

Obviously, Y is a discrete random variable with the possible values . . . ,yi. . ., so that the probability ofyiis

pi= Z yi+1

yi

f(x)dx≈ f(yi)∆yi and thus, the expected value oft(Y)is

We know that the average of the function values of the experimental results of a discrete random variable is close to its expected value, so

t(Y1) +t(Y2) +. . .+t(YN)

N ≈

i

t(yi)pi From all these approximations we get that

t(X1) +t(X2) +. . .+t(XN)

N ≈

Z

−∞t(x)f(x)dx The expected value ofXnis called thenth momentofX:

E(Xn) = Z

−∞

xnf(x)dx specifically, thesecond momentofX is:

E X2

= Z

−∞

x2f(x)dx

The expected value of(X−c)nis called thenth momentabout a the pointc:

E((X−c)n) = Z

−∞(x−c)nf(x)dx specifically, thesecond momentabout a pointcis:

E (X−c)2

= Z

−∞

(x−c)2f(x)dx Second moment of some continuous distributions:

1. Uniform distribution on an interval(A;B) E X2

= A2+AB+B2 3

tankonyvtar.ttk.bme.hu Vetier András, BME

Part III. Continous distributions in one-dimension 163

Here we recognize that the integral in the last line is the expected value of the λ -parametric exponential distribution, which is equal to 1

λ, so we get as it was stated.

File to study the expected value of several functions of RND.

Demonstration file: E(t(RND)), expected value of functions of a random number 200-58-00

Vetier András, BME tankonyvtar.ttk.bme.hu

Section 49

***Median

In this chapter, we learn about the notion of the median, which is a kind of a "center" of a data-set or of a distribution. In the next chapter, we will learn the notion of the expected value also for continuous random variables and distributions, which is a kind of "center", too, and then we will be able to compare them.

If a data-set consists ofnnumbers, then we may find the smallest of these numbers, let us denote it byz1, the second smallest, let us denote it byz2,

the third smallest, let us denote it byz3, and so on,

thekth smallest, let us denote it byzk, and so on,

thenth smallest, which is actually the largest, let us denote it byzn.

Using Excel.In Excel, for a data-set, the functionSMALL(in Hungarian:KICSI) can be used to find thekth smallest element in anarray:

zk =SMALL(array;k)

Now we may arrange the numbers z1,z2, . . . ,zn in the increasing order: z1,z2, . . . ,zn. If the number n is odd, then there is a well defined center element in the list z1,z2, . . . ,zn. This center element is called the median of the data-set. If nis even, then there are two center elements. In this case, the average of these two center elements is themedian of the data-set.

Using Excel. In Excel, for a data-set, the functionMEDIAN(in Hungarian: MEDIÁN) is used to calculate the median of a data-set:

MEDIAN(array)

Themedianof a continuous random variable or distribution is the valuecfor which it is true that both the probability of being less than c and the probability of being greater than c is equal to 12:

P((−∞,c)) = 1 2 164

Part III. Continous distributions in one-dimension 165

P((c,∞)) = 1 2 The median is the solution to the equation

F(x) = 1 2

For a continuous distribution, this equation has a solution. If the inverse ofF(x)exists, and it is denoted byF−1(y), then

c=F−1 1

2

Using the density function, the median can be characterized obviously by the property Z c

The notion of the median can be defined for discrete distributions, too, but the definition is a little bit more complicated. The medianof a discrete random variable or distribution is the value c for which it is true that both the probability of being less thanc at least 12 and the probability of being greater thancat least 12:

P((−∞,c))≥ 1 2 P((−∞,c))≥ 1 2

In a long sequence of experiments, the median of the experimental results for a random vari-able stabilizes around the median of the distribution of the random varivari-able: ifX1,X2, . . . ,XN are experimental results for a random variableX, andNis large, then the median of the

data-setX1,X2, . . . ,XN, the so called experimental median is close to the median of the distribution

of the random variable.

Here is a file to study the notion of the median.

Demonstration file: Median of the exponential distribution 200-57-00

Minimal property of the median. If X is continuous random variable with the density function f(x), andcis a constant, then the expected value of the distance betweenX andcis

E(|X−c|) = Z

−∞

|x−c| f(x)dx

Vetier András, BME tankonyvtar.ttk.bme.hu

166 PROBABILITY THEORY WITH SIMULATIONS

This integral is minimal ifcis the median.

Proof.Let us denote the value of the integral, which depends onc, byh(c) h(c) = Let us take the derivative of each term with respect toc:

Now adding the 6 terms on the right sides, the termsc f(c) cancel each other, and what we get is

h0(c) =1−2F(c) Since the equation

1−2F(c) =0 is equivalent to the equation

F(c) =1/2 and the solution to this equation is the median, we get that

h0(c) =1−2F(c) =0 if c=median

tankonyvtar.ttk.bme.hu Vetier András, BME

Part III. Continous distributions in one-dimension 167

h0(c) =1−2F(c)<0 if c<median h0(c) =1−2F(c)>0 if c>median which means that the minimum ofh(c)occurs ifc=median.

Vetier András, BME tankonyvtar.ttk.bme.hu

Section 50

In document PROBABILITY THEORY WITH SIMULATIONS (Pldal 164-171)