Global Sources
EE Times - IndiaWebsite
Stay in touch with EE Times India
eeBlog-Article content Home / eeBlog / 

Profile
Nickname: Jack Crenshaw     Articles(30)    Visits(67542)    Comments(3)    Votes(5)    RSS
Jack Crenshaw's column features algorithms and plug-and-play routines, along with explanations of how they work.
Blog Archive:
2013 -  May
2011 -  Jun.,  May.,  Mar
View All

Posted: 02:54:04 PM, 16/05/2013

Grasping the normal distribution (Part 4)

   

[Continued from Grasping the normal distribution (Part 3)]

 

<b>What if I <i>want</i> areas?</b>
As we've discussed, the sum of the probabilities for all possible results must add up to unity. And indeed they do, in <b>Figure 8</b>. If, for a given "curve," you add up all the <i>y</i>-axis values at the marker points, you will absolutely get 1.0. <p>
But what if we actually <i>prefer</i> the "curves" to be shown such that they enclose equal areas? In that case, we have one more transformation to perform. <p>
<b>Figure 5</b> gives us a hint. In that graph, the width of each bar&#8212;call it <i>&#916;x</i>&#8212;is exactly equal to 1. So the area of the bar is the same as its height. Mathematically, we can say: <p>
(17) <p>
In this special case, adding up all the occurrences is the same thing as computing the total area, which had better come out to be 7,776. <p>
The situation is the same in <b>Figure 8</b>. Now the graph is showing probabilities, but the width of the (not very apparent) bar is still unity, so the area of the bar is: <p>
(18) <p>
Adding them all up, we should get: <p>
(19) <p>
Why would I want to include this new parameter, <i>&#916;x</i>, if its value is unity anyhow? For two reasons. First, the variable <i>x</i> may have units, like meters, volts, or pomegranates. The parameter <i>&#916;x</i> might have the <i>value</i> 1, but it will still have the same <i>units</i> as <i>x</i>. Mixing parameters with and without units is not allowed. <p>
More importantly, I just got through <i>scaling</i> the curves to force them onto the same horizontal range. In doing so, I multiplied by the scale factor given in <b>Equation 16</b>. Now I see that this scale factor is in fact the very same thing as <i>&#916;x</i>. In the figure, you can see that the marker points are getting closer together as we add dice to the experiment. As in <b>Equation 19</b>, the total area is no longer unity, but <i>&#916;x</i>. <p>
To force the curves to have areas of unity, I have to divide the <i>y</i>-values by <i>&#916;x</i> again. Since these values are no longer probabilities, I'll just call them <i>y</i>. <b>Figure 9</b> shows the results. <p>
<b>Now you see it ...</b>
Now <i>here's</i> a graph we can learn to love. Now that we have equal areas under each curve, we can see more clearly how they morph to look more like continuous curves. Not only do the (apparent) curves get smoother as we add dice, but the peak also gets higher, while the sides pinch in to maintain the equal area requirement. <p>
But hang on ... is that a fifth curve I spy? According to the legend, the dotted black line is something called "<i>Normal</i>." Unlike the other "curves," it's a truly continuous curve. <p>
That, my friends, is the <i>normal distribution function</i>. It's taken us awhile to get to it, but the evidence of <b>Figure 9</b> is overwhelming. If, seeing <b>Figure 9</b>, you still aren't convinced that the sum of separate random processes trends to the bell curve of the normal distribution, there's no hope for you. <p>
<b>Sum vs. integral</b><br>Before we go forward, I want to call your attention to a very important aspect of <b>Figure 9</b>. As you know, the two-dice through five-dice "curves" are not really curves at all, but discrete functions, with <i>y</i>-values that only exist at the marker points. But the curve labelled "normal" is very much a continuous curve. <p>
It's not often that you get to see both discrete and continuous functions on the same graph. How did we do this? <p>
The answer becomes clear when you compare the area under the curves. When I scaled the <i>y</i>-axis values to force the areas for the discrete curves to be unity, I required: <p>
(20) <p>
For the continuous curve, I require: <p>
(21) <p>
See how the two formulas complement each other? For the discrete version, we're measuring the area of a bar whose height is <I>P</I>(<i>n</i>), and whose width is <i>&#916;x</i>. Similarly, for the continuous function <i>p</i>(<i>x</i>) we get the area by integrating it over all real numbers. So what is this new function <i>p</i>(<i>x</i>)? <p>
Well, it's a probability all right, but it's not just a probability that a measurement is exactly the same as the x-axis value. Since <i>x</i> can range over all numbers, the probability that the result is exactly equal to <i>x</i> is zero. <p>
Instead, <i>p</i>(<i>x</i>) is the probability that the measurement fall into an infinitesimally narrow range, <i>between</i> <i>x</i> and <i>x</i>&#43;<i>dx</i>. <p>
<b>The math of it all</b><br>Now that you've seen the curve, I still must show you the math behind it. Here again, I'm given the opportunity to derive the math from first principles. But I'm going to duck it again. As I mentioned earlier, the classical derivation is pretty horrible. If you'd like to see it done the easy way, see the exquisite paper <p>
<i>The Normal Distribution: A derivation from basic principles</i>, Dan Teague, North Carolina School of Science and Mathematics
<a href="http://courses.ncssm.edu/math/Talks/PDFS/normal.pdf" target="blank">http://courses.ncssm.edu/math/Talks/PDFS/normal.pdf</a><p>
To learn all there is to know about the normal distribution (including its origin, inspired by a gambler), see the exhaustive study by Saul Stahl: <p>
"Evolution of the Normal Distribution," Saul Stahl, <i>Mathematics Magazine</i>, Vol. 79, No. 2, April 2006, pp. 96-113<p>
<a href="http://mathdl.maa.org/images/upload_library/22/Allendoerfer/stahl96.pdf" target="blank">http://mathdl.maa.org/images/upload_library/22/Allendoerfer/stahl96.pdf</a><p>
As for my "derivation," I'm going to follow the example set by J. Willard Gibbs, the father of statistical mechanics, circa 1900. He said (and I paraphrase), "We use this form because it's the simplest one we can think of, that works." Now, <i>that's</i> my kind of physicist! <p>
Take another look at the shapes in <b>Figure 9</b>. There are a lot of things we can say about them, without knowing anything about the mathematical formula underlying them. Indeed, if we'd been clever enough, we could have said these things from the outset. These things are: <p>
- The most probable value of <i>x</i> (the peak of the distribution) should be zero
- The distribution should decrease monotonically as <i>x</i> moves away from zero
- The functions should be symmetric around zero
- It should tail off to zero at the extremes (which are &#177;&#8734;)<p>
As soon as you hear the words, "tail off to zero," you should be thinking of an exponential function. One function that does this is: <p>
(22)
But that one's no good, because it's not symmetric. In fact, it grows to infinity as <i>x</i> goes more and more negative. <p>
So what's the next simplest function we can think of? Why, it's the one that doesn't care if <i>x</i> is positive or negative: <p>
(23) <p>
This is the function Sir Willard used, and if it's good enough for him. it's good enough for me. <b>Figure 10</b> shows the function in all its glory. <p>
That's definitely the shape we want. We still have to add some bric-a-brac to make it functional, but the shape is perfect. <p>
<b>The area</b><br>By now we should be very comfortable by the fact that any probability distribution curve must include an area equal to unity. Does this one? Let's find out. The area under the curve of <b>Figure 10</b> is: <p>
(24)
Did you see that I had to integrate from -&#8734; to &#43;&#8734;, which is of course the full range of real numbers? The function in <b>Figure 10</b> sure looks as though there's little or no area out past <i>x</i>=&#177;4 , but since the function never quite gets to zero, we still have to include those tiny slivers of area out in the suburbs. <p>
Now, what's the value of the integral? We can find it in a number of ways. If you're feeling adventurous and like to do things from first principles (as I usually do), you can derive the integral yourself. It's fairly easy, but not at all obvious. See how here: <p>
<a href="http://www.youtube.com/watch?v=fWOGfzC3IeY" target="blank">http://www.youtube.com/watch?v=fWOGfzC3IeY</a><p>
If you still have your book called <i>Tables of Integrals</i>, you can simply look up the answer. Your book is probably not the same as mine&#8212;mine was Pierce, printed in 1939. <p>
Or, you can do as I did: Ask Mathcad, who says: <p>
(25) <p>
Noting very astutely that <b>[INSERT IMAGE HERE]</b> is not the same thing as 1, I see that I must modify <b>Equation 23</b> to read: <p>
(26) <p>
In this form, the function has an integral of 1, so it's earned the right to be called a probability distribution function (hence the name change). Note that the height of the central peak of <i>p(x)</i> occurs when <i>x</i> = 0, where it's clearly: <p>
(27) <p>
<b>On the home stretch</b><br>As you'll recall, in building <b>Figure 9</b> I had to shrink and stretch the <I>N</I>-dice "curves" to force them onto the same <i>x</i>-axis interval (&#177;1) and keep their areas equal. We need to be able to do something similar for <i>p</i>(<i>x</i>). The new multiplying constant takes care of the area constraint, but we still need to be able to scale the <i>x</i>-axis width. I think it's safe to say that we won't always want the width of the central peak to be about &#177;2 or so. Even if we did, we still need a scale factor on <i>x</i>, because remember, <i>x</i> can&#8212;and often does&#8212;have units. I'm pretty sure that I don't know how to raise <i>e</i> to the power 1.618 <i>pomegranates</i>.<sup>2</sup> <p>
To take care of this, let's make the change of variables: <p>
(28) <p>
I'm sure you must be wondering where that factor of 2 came from. It seems like an unnecessary complexity, added for no good reason. Actually, there <i>is</i> a good reason&#8212;even a very good reason&#8212;but it won't be apparent until later. For now, just trust me, Ok? <p>
Note carefully that it's not enough to just substitute for <i>x</i> in <b>Equation 26</b>. If we try to just stretch or shrink the horizontal scale, the function will still have the same height, so the area will change. We really need to go back to <b>Equation 24</b> and evaluate the integral again. Differentiating the last of <b>Equation 28</b> gives: <p>
(29) <p>
Substituting for both <i>x</i> and <i>dx</i> in <b>Equation 24</b> gives the new integral: <p>
(30) <p>
Since we're integrating over the range &#177;&#8734;, the changes to the exponent don't matter. <b>[INSERT IMAGE HERE]</b> times infinity is still infinity. So the integral still evaluates to <b>[INSERT IMAGE HERE]</b>, which makes the new area: <p>
(31) <p>
And our function now takes the form: <p>
(32) <p>
<b>I mean...</b>
There is one last little tweak to <i>p</i>(<i>x</i>). Sometimes, people need to translate the <i>x</i>-component so that the central peak no longer occurs at <i>x</i> = 0. This isn't so much a problem for us, because when you're dealing with noise, it's most likely value will always be zero. But for the sake of completeness, here is the normal distribution function in its most general form. <p>
(33) <p>
As you can see, we now have two parameters we can adjust to match the situation. The constant&#181; is an additive factor to shift the peak left and right, while &#963; allows for scaling (and possibly removing the units of) <i>x</i>. <p>
These two parameters have names, and those names&#8212;which come from the science of statistics&#8212;should be familiar to you.&#181; is the <i>mean</i>, and &#963; is the <i>standard deviation</i>. As my last trick for this column, I'll prove to you that these names fit the statistical definitions of these parameters. <p>
Because we had to scale <i>x</i>, we now have a factor of &#963; in the multiplicative constant. This means, or course, that the height of the central peak will change as we vary &#963;. <p>
<b>The expectation value</b><br>Let's look back for a moment, to the things we were doing with dice. For any number of dice, I showed you the histograms, which can be easily turned into probability distributions using <b>Equation 10</b>. Until now, we've only concerned ourselves with the probabilities of having a certain result, like 2, 12, or 7. But what if the thing we're interested in is not the result itself, but something that <i>depends</i> on it? To stick with the dice-game theme, what if you get, say, $10 every time you roll two dice and get a 4, but only $2 if you roll a 9 (which, you may recall, has the same probability: 1/9). In that case, it's not enough just to know the probability of getting a certain result from a dice roll; you also need to know what happens when you get that roll. In other words, you need the rules of the game. <p>
To take another example, suppose I buy a $1 lottery ticket, for a pot that's currently worth $300,000,000. What can I expect to get out of the deal? Well, one thing's for sure: It's not the 300 mill, because my likelihood of winning is very, very low. <p>
There's a mathematical term for this concept, and it's the same one the gamblers use. The only difference is that the gamblers were using it several thousand years earlier. The term is called <i>expectation value</i>. <p>
Mathematically, if <I>P</I> is the probability of winning, and v the payout value, then the expectation value of my lottery ticket is: <p>
(34) <p>
Here I've shown two popular notations for the expectation value. I tend to prefer the angle-bracket notation (..), because it's completely unambiguous. But the E(..) notation seems more popular lately. <p>
The same principle works for games like the dice game, only then we need to compute the average of all possible outcomes. If there are <i>n</i> possible outcomes from a given dice roll, then the expectation value becomes: <p>
(35) <p>
Now that we see the concept, it's easy enough to extend it to the case of continuous functions. If <i>f(x)</i> represents some function of <i>x</i> (the rules of the game, if you will), then its expectation value is: <p>
(36) <p>
This important integral embodies the central idea of how to deal with random processes. <p>
For everything we'll be doing from now on, we'll be using the normal distribution, so we might as well insert it into <b>Equation 36</b> explicitly, to get: <p>
(37) <p>
Just to emphasize: This definition works for any function <i>f</i>(<i>x</i>)&#8212;at least, any "well-behaved" function, meaning that it doesn't have any internal infinities. Of course, there's no guarantee that we'll be able to get a closed-form solution; we might have to resort to a numerical method such as Simpson's rule. <p>
 

[To be continued at Grasping the normal distribution (Part 5)]

Label:
Views(3109) Comments(0)
Total [0] users voted     
[Last update: 01:46:26 PM, 21/05/2013]
CONTACT US TO OWN A BLOGNew!  

Have Your Say!

Got something to say? Why not share itwith other engineers?

CONTACT US TO OWN ONE!

SEE WHAT OTHERS HAVE SAID?

Top eeBlog Keywords

1.  arduino

2.  software

3.  power

4.  code

5.  embedded

Happening Now...

Pulse of the industry

eeForum homepage

 
Back to Top