Statistics/Print version

From Wikibooks, open books for an open world
< Statistics
Jump to: navigation, search


Statistics

The current, editable version of this book is available in Wikibooks, the open-content textbooks collection, at
http://en.wikibooks.org/wiki/Statistics

Permission is granted to copy, distribute, and/or modify this document under the terms of the Creative Commons Attribution-ShareAlike 3.0 License.

Contents


Introduction[edit]

What is Statistics[edit]

Your company has created a new drug that may cure arthritis. How would you conduct a test to confirm the drug's effectiveness?

The latest sales data have just come in, and your boss wants you to prepare a report for management on places where the company could improve its business. What should you look for? What should you not look for?

You and a friend are at a baseball game, and out of the blue he offers you a bet that neither team will hit a home run in that game. Should you take the bet?

You want to conduct a poll on whether your school should use its funding to build a new athletic complex or a new library. How many people do you have to poll? How do you ensure that your poll is free of bias? How do you interpret your results?

A widget maker in your factory that normally breaks 4 widgets for every 100 it produces has recently started breaking 5 widgets for every 100. When is it time to buy a new widget maker? (And just what is a widget, anyway?)

These are some of the many real-world examples that require the use of statistics.

How would you approach the problem statements ? There are some stepwise human algorithms, but is there a general problem statement ?

"Find possible solutions, decide on a solution, plan the solution, implement the solution, learn from the results for future solutions (or re-solution)."

"SOAP - subjective - the problem as given, objective - the problem after examination, assessment - the better defined problem, plan - decide if guidelines to management already exist, and blueprint the solution for this case, or generate a risk-minimizing, new solution path".

"HAMRC - hypothesis, aim, methodology, results, conclusion" - the concept that there is no real difference is the null hypothesis.

Then there is the joke that compares the different ways of thinking:

"A physicist, a chemist and a statistician were working collaboratively on a problem, when the wastepaper basket spontaneously combusted (they all sweared they had stopped smoking). The chemist said, 'quick, we must reduce the concentration of the reactant which is oxygen, by increasing the relative concentration of non-reactive gases, such as carbon dioxide and carbon monoxide. Place a fire blanket over the flames. ' The physicist, interjected, 'no, no, we must reduce the heat energy available for activating combustion ; get some water to douse the flame'. Meanwhile, the statistician was running around lighting more fires. The others asked with alarm, 'what are you doing?'. 'Trying to get an adequate sample size' ."


General Definition[edit]

Statistics, in short, is the study of data. It includes descriptive statistics (the study of methods and tools for collecting data, and mathematical models to describe and interpret data) and inferential statistics (the systems and techniques for making probability-based decisions and accurate predictions.

Etymology[edit]

As its name implies, statistics has its roots in the idea of "the state of things". The word itself comes from the ancient Latin term statisticum collegium, meaning "a lecture on the state of affairs". Eventually, this evolved into the Italian word statista, meaning "statesman", and the German word Statistik, meaning "collection of data involving the State". Gradually, the term came to be used to describe the collection of any sort of data.


Statistics as a subset of mathematics[edit]

As one would expect, statistics is largely grounded in mathematics, and the study of statistics has lent itself to many major concepts in mathematics: probability, distributions, samples and populations, the bell curve, estimation, and data analysis.

Up ahead[edit]

Up ahead, we will learn about subjects in modern statistics and some practical applications of statistics. We will also lay out some of the background mathematical concepts required to begin studying statistics.


Subjects in Modern Statistics[edit]

A remarkable amount of today's modern statistics comes from the original work of R.A. Fisher in the early 20th Century. Although there are a dizzying number of minor disciplines in the field, there are some basic, fundamental studies.

The beginning student of statistics will be more interested in one topic or another depending on his or her outside interest. The following is a list of some of the primary branches of statistics.

Probability Theory and Mathematical Statistics[edit]

Those of us who are purists and philosophers may be interested in the intersection between pure mathematics and the messy realities of the world. A rigorous study of probability—especially the probability distributions and the distribution of errors—can provide an understanding of where all these statistical procedures and equations come from. Although this sort of rigor is likely to get in the way of a psychologist (for example) learning and using statistics effectively, it is important if one wants to do serious (i.e. graduate-level) work in the field.

That being said, there is good reason for all students to have a fundamental understanding of where all these "statistical techniques and equations" are coming from! We're always more adept at using a tool if we can understand why we're using that tool. The challenge is getting these important ideas to the non-mathematician without the student's eyes glazing over. One can take this argument a step further to claim that a vast number of students will never actually use a t-test—he or she will never plug those numbers into a calculator and churn through some esoteric equations—but by having a fundamental understanding of such a test, he or she will be able to understand (and question) the results of someone else's findings.

Design of Experiments[edit]

One of the most neglected aspects of statistics—and maybe the single greatest reason that Statisticians drink—is Experimental Design. So often a scientist will bring the results of an important experiment to a statistician and ask for help analyzing results only to find that a flaw in the experimental design rendered the results useless. So often we statisticians have researchers come to us hoping that we will somehow magically "rescue" their experiments.

A friend provided me with a classic example of this. In his psychology class he was required to conduct an experiment and summarize its results. He decided to study whether music had an impact on problem solving. He had a large number of subjects (myself included) solve a puzzle first in silence, then while listening to classical music and finally listening to rock and roll, and finally in silence. He measured how long it would take to complete each of the tasks and then summarized the results.

What my friend failed to consider was that the results were highly impacted by a learning effect he hadn't considered. The first puzzle always took longer because the subjects were first learning how to work the puzzle. By the third try (when subjected to rock and roll) the subjects were much more adept at solving the puzzle, thus the results of the experiment would seem to suggest that people were much better at solving problems while listening to rock and roll!

The simple act of randomizing the order of the tests would have isolated the "learning effect" and in fact, a well-designed experiment would have allowed him to measure both the effects of each type of music and the effect of learning. Instead, his results were meaningless. A careful experimental design can help preserve the results of an experiment, and in fact some designs can save huge amounts of time and money, maximize the results of an experiment, and sometimes yield additional information the researcher had never even considered!

Sampling[edit]

Similar to the Design of Experiments, the study of sampling allows us to find a most effective statistical design that will optimize the amount of information we can collect while minimizing the level of effort. Sampling is very different from experimental design however. In a laboratory we can design an experiment and control it from start to finish. But often we want to study something outside of the laboratory, over which we have much less control.

If we wanted to measure the population of some harmful beetle and its effect on trees, we would be forced to travel into some forest land and make observations, for example: measuring the population of the beetles in different locations, noting which trees they were infesting, measuring the health and size of these trees, etc.

Sampling design gets involved in questions like "How many measurements do I have to take?" or "How do I select the locations from which I take my measurements?" Without planning for these issues, researchers might spend a lot of time and money only to discover that they really have to sample ten times as many points to get meaningful results or that some of their sample points were in some landscape (like a marsh) where the beetles thrived more or the trees grew better.

Modern Regression[edit]

Regression models relate variables to each other in a linear fashion. For example, if you recorded the heights and weights of several people and plotted them against each other, you would find that as height increases, weight tends to increase too. You would probably also see that a straight line through the data is about as good a way of approximating the relationship as you will be able to find, though there will be some variability about the line. Such linear models are possibly the most important tool available to statisticians. They have a long history and many of the more detailed theoretical aspects were discovered in the 1970s. The usual method for fitting such models is by "least squares" estimation, though other methods are available and are often more appropriate, especially when the data are not normally distributed.

What happens, though, if the relationship is not a straight line? How can a curve be fit to the data? There are many answers to this question. One simple solution is to fit a quadratic relationship, but in practice such a curve is often not flexible enough. Also, what if you have many variables and relationships between them are dissimilar and complicated?

Modern regression methods aim at addressing these problems. Methods such as generalized additive models, projection pursuit regression, neural networks and boosting allow for very general relationships between explanatory variables and response variables, and modern computing power makes these methods a practical option for many applications

Classification[edit]

Some things are different from others. How? That is, how are objects classified into their respective groups? Consider a bank that is hoping to lend money to customers. Some customers who borrow money will be unable or unwilling to pay it back, though most will pay it back as regular repayments. How is the bank to classify customers into these two groups when deciding which ones to lend money to?

The answer to this question no doubt is influenced by many things, including a customer's income, credit history, assets, already existing debt, age and profession. There may be other influential, measurable characteristics that can be used to predict what kind of customer a particular individual is. How should the bank decide which characteristics are important, and how should it combine this information into a rule that tells it whether or not to lend the money?

This is an example of a classification problem, and statistical classification is a large field containing methods such as linear discriminant analysis, classification trees, neural networks and other methods.

Time Series[edit]

Many types of research look at data that are gathered over time, where an observation taken today may have some correlation with the observation taken tomorrow. Two prominent examples of this are the fields of finance (the stock market) and atmospheric science.

We've all seen those line graphs of stock prices as they meander up and down over time. Investors are interested in predicting which stocks are likely to keep climbing (i.e. when to buy) and when a stock in their portfolio is falling. It is easy to be misled by a sudden jolt of good news or a simple "market correction" into inferring—incorrectly—that one or the other is taking place!

In meteorology scientists are concerned with the venerable science of predicting the weather. Whether trying to predict if tomorrow will be sunny or determining whether we are experiencing true climate changes (i.e. global warming) it is important to analyze weather data over time.

Survival Analysis[edit]

Suppose that a pharmaceutical company is studying a new drug which it is hoped will cause people to live longer (whether by curing them of cancer, reducing their blood pressure or cholesterol and thereby their risk of heart disease, or by some other mechanism). The company will recruit patients into a clinical trial, give some patients the drug and others a placebo, and follow them until they have amassed enough data to answer the question of whether, and by how long, the new drug extends life expectancy.

Such data present problems for analysis. Some patients will have died earlier than others, and often some patients will not have died before the clinical trial completes. Clearly, patients who live longer contribute informative data about the ability (or not) of the drug to extend life expectancy. So how should such data be analyzed?

Survival analysis provides answers to this question and gives statisticians the tools necessary to make full use of the available data to correctly interpret the treatment effect.

Categorical Analysis[edit]

In laboratories we can measure the weight of fruit that a plant bears, or the temperature of a chemical reaction. These data points are easily measured with a yardstick or a thermometer, but what about the color of a person's eyes or her attitudes regarding the taste of broccoli? Psychologists can't measure someone's anger with a measuring stick, but they can ask their patients if they feel "very angry" or "a little angry" or "indifferent". Entirely different methodologies must be used in statistical analysis from these sorts of experiments. Categorical Analysis is used in a myriad of places, from political polls to analysis of census data to genetics and medicine.

Clinical Trials[edit]

In the United States, the FDA requires that pharmaceutical companies undergo rigorous procedures called Clinical Trials and statistical analyses to assure public safety before allowing the sale of use of new drugs. In fact, the pharmaceutical industry employs more statisticians than any other business!

Further reading[edit]


Why Should I Learn Statistics?[edit]

Imagine reading a book for the first few chapters and then becoming able to get a sense of what the ending will be like - this is one of the great reasons to learn statistics. With the appropriate tools and solid grounding in statistics, one can use a limited sample (e.g. read the first five chapters of Pride & Prejudice) to make intelligent and accurate statements about the population (e.g. predict the ending of Pride & Prejudice). This is what knowing statistics and statistical tools can do for you.

In today's information-overloaded age, statistics is one of the most useful subjects anyone can learn. Newspapers are filled with statistical data, and anyone who is ignorant of statistics is at risk of being seriously misled about important real-life decisions such as what to eat, who is leading the polls, how dangerous smoking is, etc. Knowing a little about statistics will help one to make more informed decisions about these and other important questions. Furthermore, statistics are often used by politicians, advertisers, and others to twist the truth for their own gain. For example, a company selling the cat food brand "Cato" (a fictitious name here), may claim quite truthfully in their advertisements that eight out of ten cat owners said that their cats preferred Cato brand cat food to "the other leading brand" cat food. What they may not mention is that the cat owners questioned were those they found in a supermarket buying Cato.

“The best thing about being a statistician is that you get to play in everyone else’s backyard.” John Tukey, Princeton University

More seriously, those proceeding to higher education will learn that statistics is the most powerful tool available for assessing the significance of experimental data, and for drawing the right conclusions from the vast amounts of data faced by engineers, scientists, sociologists, and other professionals in most spheres of learning. There is no study with scientific, clinical, social, health, environmental or political goals that does not rely on statistical methodologies. The basic reason for that is that variation is ubiquitous in nature and probability and statistics are the fields that allow us to study, understand, model, embrace and interpret variation.

See Also UCLA Brochure on Why Study Probability & Statistics


What Do I Need to Know to Learn Statistics?[edit]

Statistics is a diverse subject and thus the mathematics that are required depend on the kind of statistics we are studying. A strong background in linear algebra is needed for most multivariate statistics, but is not necessary for introductory statistics. A background in Calculus is useful no matter what branch of statistics is being studied, but is not required for most introductory statistics classes.

At a bare minimum the student should have a grasp of basic concepts taught in Algebra and be comfortable with "moving things around" and solving for an unknown. Most of the statistics here will derive from a few basic things that the reader should become acquainted with.

Absolute Value[edit]

|x| \equiv \begin{cases}
			x, & x \ge 0 \\
			-x, & x < 0
		\end{cases}


If the number is zero or positive, then the absolute value of the number is simply the same number. If the number is negative, then take away the negative sign to get the absolute value.

Examples[edit]

  • |42| = 42
  • |-5| = 5
  • |2.21| = 2.21

Factorials[edit]

A factorial is a calculation that gets used a lot in probability. It is defined only for integers greater-than-or-equal-to zero as:


n!  \equiv \begin{cases}
			n \cdot (n-1)!, & n \ge 1 \\
			1,  & n = 0
		\end{cases}

Examples[edit]

In short, this means that:

0! = 1 = 1
1! = 1 · 1 = 1
2! = 2 · 1 = 2
3! = 3 · 2 · 1 = 6
4! = 4 · 3 · 2 · 1 = 24
5! = 5 · 4 · 3 · 2 · 1 = 120
6! = 6 · 5 · 4 · 3 · 2 · 1 = 720

Summation[edit]

The summation (also known as a series) is used more than almost any other technique in statistics. It is a method of representing addition over lots of values without putting + after +. We represent summation using a big uppercase sigma: ∑.

Examples[edit]

Very often in statistics we will sum a list of related variables:


	\sum_{i=0}^n x_i = x_0 + x_1 + x_2 + \cdots + x_n

Here we are adding all the x variables (which will hopefully all have values by the time we calculate this). The expression below the ∑ (i=0, in this case) represents the index variable and what its starting value is (i with a starting value of 0) while the number above the ∑ represents the number that the variable will increment to (stepping by 1, so i = 0, 1, 2, 3, and then 4). Another example:


\sum_{i=1}^4 2i = 2(1) + 2(2) + 2(3) + 2(4) = 2 + 4 + 6 + 8 = 20

Notice that we would get the same value by moving the 2 outside of the summation (perform the summation and then multiply by 2, rather than multiplying each component of the summation by 2).

Infinite series[edit]

There is no reason, of course, that a series has to count on any determined, or even finite value—it can keep going without end. These series are called "infinite series" and sometimes they can even converge to a finite value, eventually becoming equal to that value as the number of items in your series approaches infinity (∞).

Examples[edit]

\sum_{k=0}^\infty r^k = \frac{1}{1-r}, \left| r \right| < 1

This example is the famous geometric series. Note both that the series goes to ∞ (infinity, that means it does not stop) and that it is only valid for certain values of the variable r. This means that if r is between the values of -1 and 1 (-1 < r < 1) then the summation will get closer to (i.e., converge on) 1 / 1-r the further you take the series out.

Linear Approximation[edit]

Student-t Distribution at various critical values with varying degrees of freedom.
v / α 0.20 0.10 0.05 0.025 0.01 0.005
40 0.85070 1.30308 1.68385 2.02108 2.42326 2.70446
50 0.84887 1.29871 1.67591 2.00856 2.40327 2.67779
60 0.84765 1.29582 1.67065 2.00030 2.39012 2.66028
70 0.84679 1.29376 1.66691 1.99444 2.38081 2.64790
80 0.84614 1.29222 1.66412 1.99006 2.37387 2.63869
90 0.84563 1.29103 1.66196 1.98667 2.36850 2.63157
100 0.84523 1.29007 1.66023 1.98397 2.36422 2.62589


Let us say that you are looking at a table of values, such as the one above. You want to approximate (get a good estimate of) the values at 63, but you do not have those values on your table. A good solution here is use a linear approximation to get a value which is probably close to the one that you really want, without having to go through all of the trouble of calculating the extra step in the table.


f\left(x_i\right) \approx \frac{f\left(x_{\lceil i \rceil}\right) - f\left(x_{\lfloor i \rfloor}\right)}{x_{\lceil i \rceil} - x_{\lfloor i \rfloor}} \cdot \left(x_i - x_{\lfloor i \rfloor}\right) + f\left(x_{\lfloor i \rfloor}\right)

This is just the equation for a line applied to the table of data. xi represents the data point you want to know about, x_{\lfloor i \rfloor} is the known data point beneath the one you want to know about, and x_{\lceil i \rceil} is the known data point above the one you want to know about.

Examples[edit]

Find the value at 63 for the 0.05 column, using the values on the table above.

First we confirm on the above table that we need to approximate the value. If we know it exactly, then there really is no need to approximate it. As it stands this is going to rest on the table somewhere between 60 and 70. Everything else we can get from the table:

 


f(63) \approx  \frac{f(70) - f(60)}{70 - 60} \cdot (63 - 60) + f(60) = \frac{1.66691  - 1.67065}{10} \cdot 3 + 1.67065 = 1.669528

 

Using software, we calculate the actual value of f(63) to be 1.669402, a difference of around 0.00013. Close enough for our purposes.

Different Types of Data[edit]

Data are assignments of values onto observations of events and objects. They can be classified by their coding properties and the characteristics of their domains and their ranges.

Identifying data type[edit]

When a given data set is numerical in nature, it is necessary to carefully distinguish the actual nature of the variable being quantified. Statistical tests are generally specific for the kind of data being handled.

Data on a nominal (or categorical) scale[edit]

Identifying the true nature of numerals applied to attributes that are not "measures" is usually straightforward and apparent. Examples in everyday use include road, car, house, book and telephone numbers. A simple test would be to ask if re-assigning the numbers among the set would alter the nature of the collection. If the plates on a car are changed, for example, it still remains the same car in reality.

Data on an Ordinal Scale[edit]

An ordinal scale is a scale with ranks. Those ranks only have sense in that they are ordered, that is what makes it ordinal scale. The distance [rank n] minus [rank n-1] is not guaranteed to be equal to [rank n-1] minus [rank n-2], but [rank n] will be greater than [rank n-1] in the same way [rank n-1] is greater than [rank n-2] for all n where [rank n], [rank n-1], and [rank n-2] exist. Ranks of an ordinal scale may be represented by a system with numbers or names and an agreed order.

We can illustrate this with a common example: the Likert scale. Consider five possible responses to a question, perhaps Our president is a great man, with answers on this scale

Response: Strongly Disagree Disagree Neither Agree nor Disagree Agree Strongly Agree
Code: 1 2 3 4 5

Here the answers are a ranked scale reflected in the choice of numeric code. There is however no sense in which the distance between Strongly agree and Agree is the same as between Strongly disagree and Disagree.

Numerical ranked data should be distinguished from measurement data.

Measurement data[edit]

Numerical measurements exist in two forms, Meristic and continuous, and may present themselves in three kinds of scale: interval, ratio and circular.

Meristic or discrete variables are generally counts and can take on only discrete values. Normally they are represented by natural numbers. The number of plants found in a botanist's quadrant would be an example. (Note that if the edge of the quadrant falls partially over one or more plants, the investigator may choose to include these as halves, but the data will still be meristic as doubling the total will remove any fraction).

Continuous variables are those whose measurement precision is limited only by the investigator and his equipment. The length of a leaf measured by a botanist with a ruler will be less precise than the same measurement taken by micrometer. (Notionally, at least, the leaf could be measured even more precisely using a microscope with a graticule.)

Interval Scale Variables measured on an interval scale have values in which differences are uniform and meaningful but ratios will not be so. An oft quoted example is that of the Celsius scale of temperature. A difference between 5° and 10° is equivalent to a difference between 10° and 15°, but the ratio between 15° and 5° does not imply that the former is three times as warm as the latter.

Ratio Scale Variables on a ratio scale have a meaningful zero point. In keeping with the above example one might cite the Kelvin temperature scale. Because there is an absolute zero, it is true to say that 400°K is twice as warm as 200°K, though one should do so with tongue in cheek. A better day-to-day example would be to say that a 180 kg Sumo wrestler is three times heavier than his 60 kg wife.

Circular Scale When one measures annual dates, clock times and a few other forms of data, a circular scale is in use. It can happen that neither differences nor ratios of such variables are sensible derivatives, and special methods have to be employed for such data.


Primary and Secondary Data[edit]

Data can be classified as either primary or secondary.

Primary Data[edit]

Primary data means original data that has been collected specially for the purpose in mind. It means someone collected the data from the original source first hand. Data collected this way is called primary data.

The people who gather primary data may be an authorized organization, investigator, enumerator or they may be just someone with a clipboard. These people are acting as a witness so primary data is only considered as reliable as the people who gathered it.

Research where one gathers this kind of data is referred to as field research.

For example: your own questionnaire.

Secondary Data[edit]

Secondary data is data that has been collected for another purpose. When we use Statistical Method with Primary Data from another purpose for our purpose we refer to it as Secondary Data. It means that one purpose's Primary Data is another purpose's Secondary Data. Secondary data is data that is being reused. Usually in a different context.

Research where one gathers this kind of data is referred to as desk research.

For example: data from a book.

Why Classify Data This Way?[edit]

Knowing how the data was collected allows critics of a study to search for bias in how it was conducted. A good study will welcome such scrutiny. Each type has its own weaknesses and strengths. Primary Data is gathered by people who can focus directly on the purpose in mind. This helps ensure that questions are meaningful to the purpose but can introduce bias in those same questions. Secondary Data doesn't have the privilege of this focus but is only susceptible to bias introduced in the choice of what data to reuse. Stated another way, those who gather Secondary Data get to pick the questions. Those who gather Primary Data get to write the questions.

<< Different Types of Data | Statistics | >> Qualitative and Quantitative


Quantitative and qualitative data are two types of data.

Qualitative data[edit]

Qualitative data is a categorical measurement expressed not in terms of numbers, but rather by means of a natural language description. In statistics, it is often used interchangeably with "categorical" data.

  For example: favorite color = "blue"
               height = "tall"

Although we may have categories, the categories may have a structure to them. When there is not a natural ordering of the categories, we call these nominal categories. Examples might be gender, race, religion, or sport.

When the categories may be ordered, these are called ordinal variables. Categorical variables that judge size (small, medium, large, etc.) are ordinal variables. Attitudes (strongly disagree, disagree, neutral, agree, strongly agree) are also ordinal variables, however we may not know which value is the best or worst of these issues. Note that the distance between these categories is not something we can measure.

Quantitative data[edit]

Quantitative data is a numerical measurement expressed not by means of a natural language description, but rather in terms of numbers. However, not all numbers are continuous and measurable. For example, the social security number is a number, but not something that one can add or subtract.

  For example: favorite color = "450 nm" 
               height = "1.8 m"

Quantitative data always are associated with a scale measure.

Probably the most common scale type is the ratio-scale. Observations of this type are on a scale that has a meaningful zero value but also have an equidistant measure (i.e., the difference between 10 and 20 is the same as the difference between 100 and 110). For example, a 10 year-old girl is twice as old as a 5 year-old girl. Since you can measure zero years, time is a ratio-scale variable. Money is another common ratio-scale quantitative measure. Observations that you count are usually ratio-scale (e.g., number of widgets). .. A more general quantitative measure is the interval scale. Interval scales also have a equidistant measure. However, the doubling principle breaks down in this scale. A temperature of 50 degrees Celsius is not "half as hot" as a temperature of 100, but a difference of 10 degrees indicates the same difference in temperature anywhere along the scale. The Kelvin temperature scale, however, constitutes a ratio scale because on the Kelvin scale zero indicates absolute zero in temperature, the complete absence of heat. So one can say, for example, that 200 Kelvin is twice as hot as 100 Kelvin.

<< Different Types of Data | Statistics

Methods of Data Collection[edit]

The main portion of Statistics is the display of summarized data. Data is initially collected from a given source, whether they are experiments, surveys, or observation, and is presented in one of four methods:

Textular Method 
The reader acquires information through reading the gathered data.
Tabular Method 
Provides a more precise, systematic and orderly presentation of data in rows or columns.
Semi-tabular Method 
Uses both textual and tabular methods.
Graphical Method 
The utilization of graphs is most effective method of visually presenting statistical results or findings.


Experiments[edit]

In a experiment the experimenter applies 'treatments' to groups of subjects. For example the experimenter may give one drug to group 1 and a different drug or a placebo to group 2, to determine the effectiveness of the drug. This is what differentiates an 'experiment' from an 'observational study'.

Scientists try to identify cause-and-effect relationships because this kind of knowledge is especially powerful, for example, drug A cures disease B. Various methods exist for detecting cause-and-effect relationships. An experiment is a method that most clearly shows cause-and-effect because it isolates and manipulates a single variable, in order to clearly show its effect. Experiments almost always have two distinct variables: First, an independent variable (IV) is manipulated by an experimenter to exist in at least two levels (usually "none" and "some"). Then the experimenter measures the second variable, the dependent variable (DV).

A simple example:

Suppose the experimental hypothesis that concerns the scientist is that reading a Wiki will enhance knowledge. Notice that the hypothesis is really an attempt to state a causal relationship like, "if you read a Wiki, then you will have enhanced knowledge." The antecedent condition (reading a Wiki) causes the consequent condition (enhanced knowledge). Antecedent conditions are always IVs and consequent conditions are always DVs in experiments. So the experimenter would produce two levels of Wiki reading (none and some, for example) and record knowledge. If the subjects who got no Wiki exposure had less knowledge than those who were exposed to Wikis, it follows that the difference is caused by the IV.

So, the reason scientists utilize experiments is that it is the only way to determine causal relationships between variables. Experiments tend to be artificial because they try to make both groups identical with the single exception of the levels of the independent variable.


Sample Surveys[edit]

Sample surveys involve the selection and study of a sample of items from a population. A sample is just a set of members chosen from a population, but not the whole population. A survey of a whole population is called a census.

A sample from a population may not give accurate results but it helps in decision making.

Examples[edit]

Examples of sample surveys:

  • Phoning the fifth person on every page of the local phonebook and asking them how long they have lived in the area. (Systematic Sample)
  • Dropping a quad. in five different places on a field and counting the number of wild flowers inside the quad. (Cluster Sample)
  • Selecting sub-populations in proportion to their incidence in the overall population. For instance, a researcher may have reason to select a sample consisting 30% females and 70% males in a population with those same gender proportions. (Stratified Sample)
  • Selecting several cities in a country, several neighbourhoods in those cities and several streets in those neighbourhoods to recruit participants for a survey (Multi-stage sample)

The term random sample is used for a sample in which every item in the population is equally likely to be selected.

Bias[edit]

While sampling is a more cost effective method of determining a result, small samples or samples that depend on a certain selection method will result in a bias within the results.

The following are common sources of bias:

  • Sampling bias or statistical bias, where some individuals are more likely to be selected than others (such as if you give equal chance of cities being selected rather than weighting them by size)
  • Systemic bias, where external influences try to affect the outcome (e.g. funding organizations wanting to have a specific result)


Observational Studies[edit]

The most primitive method of understanding the laws of nature utilizes observational studies. Basically, a researcher goes out into the world and looks for variables that are associated with one another. Notice that, unlike experiments, in an observational study the Independent Variables are not manipulated by the experimenter. The independent variable could be something like "smoking". It would be unethical and probably impossible to do an experiment where one randomly selected group is assigned to smoke and another group is assigned to the non-smoking group. Therefore, in order do determine the health effects of smoking on humans, an observational study is more appropriate than and experiment. The health of smokers and non-smokers would be compared without the experimenter assigning treatment.

Some of the foundations of modern scientific thought are based on observational research. Charles Darwin, for example, based his explanation of evolution entirely on observations he made. Case studies, where individuals are observed and questioned to determine possible causes of problems, are a form of observational research that continues to be popular today. In fact, every time you see a physician he or she is performing observational science.

There is a problem in observational science though --- it cannot ever identify causal relationships because even though two variables are related both might be caused by a third, unseen, variable. Since the underlying laws of nature are assumed to be causal laws, observational findings are generally regarded as less compelling than experimental findings.

The key way to identify experimental studies is that they involve an intervention such as the administration of a drug to one group of patients and a placebo to another group. Observational studies only collect data and make comparisons.

Medicine is an intensively studied discipline, and not all phenomenon can be studies by experimentation due to obvious ethical or logistical restrictions.


  • Case series: These are purely observational, consisting of reports of a series of similar medical cases. For example, a series of patients might be reported to suffer from bone abnormalities as well as immunodeficiencies. This association may not be significant, occurring purely by chance. On the other hand, the association may point to a mutation in common pathway affecting both the skeletal system and the immune system.
  • Case-Control: This involves an observation of a disease state, compared to normal healthy controls. For example, patients with lung cancer could be compared with their otherwise healthy neighbors. Using neighbors limits bias introduced by demographic variation. The cancer patients and their neighbors (the control) might be asked about their exposure history (did they work in an industrial setting), or other risk factors such as smoking. Another example of a case-control study is the testing of a diagnostic procedure against the gold standard. The gold standard represents the control, while the new diagnostic procedure is the "case." This might seem to qualify as an "intervention" and thus an experiment.
  • Cross-sectional: Involves many variables collected all at the same time. Used in epidemiology to estimate prevalence, or conduct other surveys.
  • Cohort: A group of subjects followed over time, prospectively. Framingham study is classic example. By observing exposure and then tracking outcomes, cause and effect can be better isolated. However this type of study cannot conclusively isolate a cause and effect relationship.
  • Historic Cohort: This is the same as a cohort except that researchers use an historic medical record to track patients and outcomes.

Data Analysis[edit]

Data analysis is one of the more important stages in our research. Without performing exploratory analyses of our data, we set ourselves up for mistakes and loss of time.

Generally speaking, our goal here is to be able to "visualize" the data and get a sense of their values. We plot histograms and compute summary statistics to observe the trends and the distribution of our data.


Data Cleaning[edit]

'Cleaning' refers to the process of removing invalid data points from a dataset.

Many statistical analyses try to find a pattern in a data series, based on a hypothesis or assumption about the nature of the data. 'Cleaning' is the process of removing those data points which are either (a) Obviously disconnected with the effect or assumption which we are trying to isolate, due to some other factor which applies only to those particular data points. (b) Obviously erroneous, i.e. some external error is reflected in that particular data point, either due to a mistake during data collection, reporting etc.

In the process we ignore these particular data points, and conduct our analysis on the remaining data.

'Cleaning' frequently involves human judgement to decide which points are valid and which are not, and there is a chance of valid data points caused by some effect not sufficiently accounted for in the hypothesis/assumption behind the analytical method applied.

The points to be cleaned are generally extreme outliers. 'Outliers' are those points which stand out for not following a pattern which is generally visible in the data. One way of detecting outliers is to plot the data points (if possible) and visually inspect the resultant plot for points which lie far outside the general distribution. Another way is to run the analysis on the entire dataset, and then eliminating those points which do not meet mathematical 'control limits' for variability from a trend, and then repeating the analysis on the remaining data.

Cleaning may also be done judgementally, for example in a sales forecast by ignoring historical data from an area/unit which has a tendency to misreport sales figures. To take another example, in a double blind medical test a doctor may disregard the results of a volunteer whom the doctor happens to know in a non-professional context.

'Cleaning' may also sometimes be used to refer to various other judgemental/mathematical methods of validating data and removing suspect data.

The importance of having clean and reliable data in any statistical analysis cannot be stressed enough. Often, in real-world applications the analyst may get mesmerised by the complexity or beauty of the method being applied, while the data itself may be unreliable and lead to results which suggest courses of action without a sound basis. A good statistician/researcher (personal opinion) spends 90% of his/her time on collecting and cleaning data, and developing hypothesis which cover as many external explainable factors as possible, and only 10% on the actual mathematical manipulation of the data and deriving results.

Summary Statistics[edit]

Summary Statistics[edit]

The most simple example of statistics "in practice" is in the generation of summary statistics. Let us consider the example where we are interested in the weight of eighth graders in a school. (Maybe we're looking at the growing epidemic of child obesity in America!) Our school has 200 eighth graders, so we gather all their weights. What we have are 200 positive real numbers.

If an administrator asked you what the weight was of this eighth grade class, you wouldn't grab your list and start reading off all the individual weights; it's just too much information. That same administrator wouldn't learn anything except that she shouldn't ask you any questions in the future! What you want to do is to distill the information — these 200 numbers — into something concise.

What might we express about these 200 numbers that would be of interest? The most obvious thing to do is to calculate the average or mean value so we know how much the "typical eighth grader" in the school weighs. It would also be useful to express how much this number varies; after all, eighth graders come in a wide variety of shapes and sizes! In reality, we can probably reduce this set of 200 weights into at most four or five numbers that give us a firm comprehension of the data set.

Averages[edit]

An average is simply a number that is representative of data. More particularly, it is a measure of central tendency. There are several types of average. Averages are useful for comparing data, especially when sets of different size are being compared. It acts as a representative figure of the whole set of data.

Perhaps the simplest and commonly used average the arithmetic mean or more simply mean which is explained in the next section.

Other common types of average are the median, the mode, the geometric mean, and the harmonic mean, each of which may be the most appropriate one to use under different circumstances.

Statistics | Summary Statistics | >> Mean, Median and Mode


Mean, Median and Mode[edit]

Mean[edit]

The mean, or more precisely the arithmetic mean, is simply the arithmetic average of a group of numbers (or data set) and is shown using -bar symbol \bar {}. So the mean of the variable x is \bar{x}, pronounced "x-bar". It is calculated by adding up all of the values in a data set and dividing by the number of values in that data set :\bar x={\sum_{}x\over n}.For example, take the following set of data: {1,2,3,4,5}. The mean of this data would be:

\bar x={\sum_{}x\over n}={1+2+3+4+5 \over 5}={15 \over 5}=3

Here is a more complicated data set: {10,14,86,2,68,99,1}. The mean would be calculated like this:

\bar x={\sum_{}x\over n}={10+14+86+2+68+99+1 \over 7}={280 \over 7}=40

Median[edit]

The median is the "middle value" in a set. That is, the median is the number in the center of a data set that has been ordered sequentially.

For example, let's look at the data in our second data set from above: {10,14,86,2,68,99,1}. What is its median?

  • First, we sort our data set sequentially: {1,2,10,14,68,85,99}
  • Next, we determine the total number of points in our data set (in this case, 7.)
  • Finally, we determine the central position of or data set (in this case, the 4th position), and the number in the central position is our median - {1,2,10,14,68,85,99}, making 14 our median.
Helpful Hint!
An easy way to determine the central position or positions for any ordered set is to take the total number of points, add 1, and then divide by 2. If the number you get is a whole number, then that is the central position. If the number you get is a fraction, take the two whole numbers on either side.

Because our data set had an odd number of points, determining the central position was easy - it will have the same number of points before it as after it. But what if our data set has an even number of points?

Let's take the same data set, but add a new number to it: {1,2,10,14,68,85,99,100} What is the median of this set?

When you have an even number of points, you must determine the two central positions of the data set. (See side box for instructions.) So for a set of 8 numbers, we get (8 + 1) / 2 = 9 / 2 = 4 1/2, which has 4 and 5 on either side.

Looking at our data set, we see that the 4th and 5th numbers are 14 and 68. From there, we return to our trusty friend the mean to determine the median. (14 + 68) / 2 = 82 / 2 = 41. find the median of 2 , 4 , 6, 8 => firstly we must count the numbers to determine its odd or even as we see it is even so we can write : M=4+6/2=10/2=5 5 is the median of above sequentiall numbers.

Mode[edit]

The mode is the most common or "most frequent" value in a data set. Example: the mode of the following data set (1, 2, 5, 5, 6, 3) is 5 since it appears twice. This is the most common value of the data set. Data sets having one mode are said to be unimodal, with two are said to be bimodal and with more than two are said to be multimodal . An example of a unimodal dataset is {1, 2, 3, 4, 4, 4, 5, 6, 7, 8, 8, 9}. The mode for this data set is 4. An example of a bimodal data set is {1, 2, 2, 3, 3}. This is because both 2 and 3 are modes. Please note: If all points in a data set occur with equal frequency, it is equally accurate to describe the data set as having many modes or no mode.

Midrange[edit]

The midrange is the arithmetic mean strictly between the minimum and the maximum value in a data set.

Relationship of the Mean, Median, and Mode[edit]

The relationship of the mean, median, and mode to each other can provide some information about the relative shape of the data distribution. If the mean, median, and mode are approximately equal to each other, the distribution can be assumed to be approximately symmetrical. If the mean > median > mode, the distribution will be skewed to the left or positively skewed. If the mean < median < mode, the distribution will be skewed to the right or negatively skewed.

Questions[edit]

1. There is an old joke that states: "Using median size as a reference it's perfectly possible to fit four ping-pong balls and two blue whales in a rowboat." Explain why this statement is true.Statistics | Mean

Geometric Mean[edit]

The Geometric Mean is calculated by taking the nth root of the product of a set of data.

\tilde{x}=\sqrt[n\;]{\prod_{i=1}^n x_i}

For example, if the set of data was:

1,2,3,4,5

The geometric mean would be calculated:

\sqrt[5]{ 1 \times 2 \times 3 \times 4 \times 5} = \sqrt[5]{120} = 2.61

Of course, with large n this can be difficult to calculate. Taking advantage of two properties of the logarithm:


\log(a\cdot b) = \log(a) + \log(b)


\log( a^n ) = n \cdot \log( a )

We find that by taking the logarithmic transformation of the geometric mean, we get:

\log\left(\sqrt[n]{ x_1 \times x_2 \times x_3 \cdots  x_n}\right) =  \frac{1}{n} \sum_{i=1}^n\log(x_i)

Which leads us to the equation for the geometric mean:

\tilde{x}= \exp \left(  \frac{1}{n} \sum_{i=1}^n\log(x_i) \right)

When to use the geometric mean[edit]

The arithmetic mean is relevant at any time several quantities add together to produce a total. The arithmetic mean answers the question, "if all the quantities had the same value, what would that value have to be in order to achieve the same total?"

In the same way, the geometric mean is relevant any time several quantities multiply together to produce a product. The geometric mean answers the question, "if all the quantities had the same value, what would that value have to be in order to achieve the same product?"

For example, suppose you have an investment which returns 10% the first year, 50% the second year, and 30% the third year. What is its average rate of return? It is not the arithmetic mean, because what these numbers mean is that on the first year your investment was multiplied (not added to) by 1.10, on the second year it was multiplied by 1.50, and the third year it was multiplied by 1.30. The relevant quantity is the geometric mean of these three numbers.

It is known that the geometric mean is always less than or equal to the arithmetic mean (equality holding only when A=B). The proof of this is quite short and follows from the fact that (\sqrt A-\sqrt B)^2 is always a non-negative number. This inequality can be surprisingly powerful though and comes up from time to time in the proofs of theorems in calculus. Source.


Harmonic Mean[edit]

The arithmetic mean cannot be used when we want to average quantities such as speed.

Consider the example below:

Example 1: The distance from my house to town is 40 km. I drove to town at a speed of 40 km per hour and returned home at a speed of 80 km per hour. What was my average speed for the whole trip?.

Solution: If we just took the arithmetic mean of the two speeds I drove at, we would get 60 km per hour. This isn't the correct average speed, however: it ignores the fact that I drove at 40 km per hour for twice as long as I drove at 80 km per hour. To find the correct average speed, we must instead calcuate the harmonic mean.

For two quantities A and B, the harmonic mean is given by: \frac{2}{\frac{1}{A} + \frac{1}{B}}

This can be simplified by adding in the denominator and multiplying by the reciprocal: \frac{2}{\frac{1}{A} + \frac{1}{B}} = \frac{2}{\frac{B + A}{AB}} = \frac{2AB}{A + B}

For N quantities: A, B, C......

Harmonic mean = \frac{N}{\frac{1}{A} + \frac{1}{B} + \frac{1}{C} + \ldots}

Let us try out the formula above on our example:

Harmonic mean = \frac{2AB}{A + B}

Our values are A = 40, B = 80. Therefore, harmonic mean = \frac{2 \times 40 \times 80}{40 + 80}= \frac{6400}{120} \approx 53.333

Is this result correct? We can verify it. In the example above, the distance between the two towns is 40 km. So the trip from A to B at a speed of 40 km will take 1 hour. The trip from B to A at a speed to 80 km will take 0.5 hours. The total time taken for the round distance (80 km) will be 1.5 hours. The average speed will then be \frac{80}{1.5} \approx 53.33 km/hour.

The harmonic mean also has physical significance.


Relationships among Arithmetic, Geometric and Harmonic Mean[edit]

The Means mentioned above are realizations of the generalized mean

 \bar{x}(m) = \left ( \frac{1}{n}\cdot\sum_{i=1}^n{|x_i|^m} \right ) ^{1/m}

and ordered this way:


\begin{alignat}{2}
&\mathit{minimum}&\;=\;&\bar{x}(-\infty) \\
\mathrel<\;&\mathit{harmonic\ mean}&\;=\;&\bar{x}(-1) \\
\mathrel<\;&\mathit{geometric\ mean}&\;=\;&\lim_{m\rightarrow0}\bar{x}(m) \\
\mathrel<\;&\mathit{arithmetic\ mean}&\;=\;&\bar{x}(1) \\
\mathrel<\;&\mathit{maximum}&\;=\;&\bar{x}(\infty)
\end{alignat}

Measures of dispersion[edit]

Range of Data[edit]

The range of a sample (set of data) is simply the maximum possible difference in the data, i.e. the difference between the maximum and the minimum values. A more exact term for it is "range width" and is usually denoted by the letter R or w. The two individual values (the max. and min.) are called the "range limits". Often these terms are confused and students should be careful to use the correct terminology.

For example, in a sample with values 2 3 5 7 8 11 12, the range is 10 and the range limits are 2 and 12.

The range is the simplest and most easily understood measure of the dispersion (spread) of a set of data, and though it is very widely used in everyday life, it is too rough for serious statistical work. It is not a "robust" measure, because clearly the chance of finding the maximum and minimum values in a population depends greatly on the size of the sample we choose to take from it and so its value is likely to vary widely from one sample to another. Furthermore, it is not a satisfactory descriptor of the data because it depends on only two items in the sample and overlooks all the rest. A far better measure of dispersion is the standard deviation (s), which takes into account all the data. It is not only more robust and "efficient" than the range, but is also amenable to far greater statistical manipulation. Nevertheless the range is still much used in simple descriptions of data and also in quality control charts.

The mean range of a set of data is however a quite efficient measure (statistic) and can be used as an easy way to calculate s. What we do in such cases is to subdivide the data into groups of a few members, calculate their average range, \bar{R} and divide it by a factor (from tables), which depends on n. In chemical laboratories for example, it is very common to analyse samples in duplicate, and so they have a large source of ready data to calculate s.

s= \frac {\bar{R}}k

(The factor k to use is given under standard deviation.)

For example: If we have a sample of size 40, we can divide it into 10 sub-samples of n=4 each. If we then find their mean range to be, say, 3.1, the standard deviation of the parent sample of 40 items is appoximately 3.1/2.059 = 1.506.

With simple electronic calculators now available, which can calculate s directly at the touch of a key, there is no longer much need for such expedients, though students of statistics should be familiar with them.


Quartiles[edit]

The quartiles of a data set are formed by the two boundaries on either side of the median, which divide the set into four equal sections. The lowest 25% of the data being found below the first quartile value, also called the lower quartile (Q1). The median, or second quartile divides the set into two equal sections. The lowest 75% of the data set should be found below the third quartile, also called the upper quartile (Q3). These three numbers are measures of the dispersion of the data, while the mean, median and mode are measures of central tendency.

Examples[edit]

Given the set {1,3,5,8,9,12,24,25,28,30,41,50} we would find the first and third quartiles as follows:

There are 12 elements in the set, so 12/4 gives us three elements in each quarter of the set.

So the first or lowest quartile is: 5, the second quartile is the median 12, and the third or upper quartile is 28.

However some people when faced with a set with an even number of elements (values) still want the true median (or middle value), with an equal number of data values on each side of the median (rather than 12 which has 5 values less than and 6 values greater than. This value is then the average of 12 and 24 resulting in 18 as the true median (which is closer to the mean of 19 2/3. The same process is then applied to the lower and upper quartiles, giving 6.5, 18, and 29. This is only an issue if the data contains an even number of elements with an even number of equally divided sections, or an odd number of elements with an odd number of equally divided sections.

Inter-Quartile Range[edit]

The inter quartile range is a statistic which provides information about the spread of a data set, and is calculated by subtracting the first quartile from the third quartile), giving the range of the middle half of the data set, trimming off the lowest and highest quarters. Since the IQR is not affected at all by outliers in the data, it is a more robust measure of dispersion than the range

IQR = Q3 - Q1

Another useful quantile is the quintiles which subdivide the data into five equal sections. The advantage of quintiles is that there is a central one with boundaries on either side of the median which can serve as an average group. In a Normal distribution the boundaries of the quintiles have boundaries ±0.253*s and ±0.842*s on either side of the mean (or median),where s is the sample standard deviation. Note that in a Normal distribution the mean, median and mode coincide.

Other frequently used quantiles are the deciles (10 equal sections) and the percentiles (100 equal sections)

Variance and Standard Deviation[edit]

Probability density function for the normal distribution. The red line is the standard normal distribution.

Measure of Scale[edit]

When describing data it is helpful (and in some cases necessary) to determine the spread of a distribution. One way of measuring this spread is by calculating the variance or the standard deviation of the data.

In describing a complete population, the data represents all the elements of the population. As a measure of the "spread" in the population one wants to know a measure of the possible distances between the data and the population mean. There are several options to do so. One is to measure the average absolute value of the deviations. Another, called the variance, measures the average square of these deviations.

A clear distinction should be made between dealing with the population or with a sample from it. When dealing with the complete population the (population) variance is a constant, a parameter which helps to describe the population. When dealing with a sample from the population the (sample) variance is actually a random variable, whose value differs from sample to sample. Its value is only of interest as an estimate for the population variance.

Population variance and standard deviation[edit]

Let the population consist of the N elements x1,...,xN. The (population) mean is:

\mu = \frac 1N \sum_{i=1}^Nx_i.

The (population) variance σ2 is the average of the squared deviations from the mean or (xi - μ)2 - the square of the value's distance from the distribution's mean.

\sigma^2 = \frac 1N  \sum_{i=1}^N (x_i - \mu)^2.

Because of the squaring the variance is not directly comparable with the mean and the data themselves. The square root of the variance is called the Standard Deviation σ. Note that σ is the root mean squared of differences between the data points and the average.

Sample variance and standard deviation[edit]

Let the sample consist of the n elements x1,...,xn, taken from the population. The (sample) mean is:

\bar{x} = \frac 1n \sum_{i=1}^nx_i.

The sample mean serves as an estimate for the population mean μ.

The (sample) variance s2 is a kind of average of the squared deviations from the (sample) mean:

s^2 = \frac 1{n-1}  \sum_{i=1}^n (x_i - \bar{x})^2.

Also for the sample we take the square root to obtain the (sample) standard deviation s


A common question at this point is "why do we square the numerator?" One answer is: to get rid of the negative signs. Numbers are going to fall above and below the mean and, since the variance is looking for distance, it would be counterproductive if those distances factored each other out.

Example[edit]

When rolling a fair die, the population consists of the 6 possible outcomes 1 to 6. A sample may consist instead of the outcomes of 1000 rolls of the die.

The population mean is:

\mu = \frac 16 (1+2+3+4+5+6) = 3.5,

and the population variance:

\sigma^2=\frac 16 \sum_{i=1}^n (i-3.5)^2=\frac 16(6.25+2.25+0.25+0.25+2.25+6.25)=\frac {35}{12} \approx 2.917

The population standard deviation is:

\sigma = \sqrt{\frac {35}{12}} \approx 1.708.

Notice how this standard deviation is somewhere in between the possible deviations.

So if we were working with one six-sided die: X = {1, 2, 3, 4, 5, 6}, then σ2 = 2.917. We will talk more about why this is different later on, but for the moment assume that you should use the equation for the sample variance unless you see something that would indicate otherwise.

Note that none of the above formulae are ideal when calculating the estimate and they all introduce rounding errors. Specialized statistical software packages use more complicated logarithms that take a second pass of the data in order to correct for these errors. Therefore, if it matters that your estimate of standard deviation is accurate, specialized software should be used. If you are using non-specialized software, such as some popular spreadsheet packages, you should find out how the software does the calculations and not just assume that a sophisticated algorithm has been implemented.

For Normal Distributions[edit]

The empirical rule states that approximately 68 percent of the data in a normally distributed dataset is contained within one standard deviation of the mean, approximately 95 percent of the data is contained within 2 standard deviations, and approximately 99.7 percent of the data falls within 3 standard deviations.


As an example, the verbal or math portion of the SAT has a mean of 500 and a standard deviation of 100. This means that 68% of test-takers scored between 400 and 600, 95% of test takers scored between 300 and 700, and 99.7% of test-takers scored between 200 and 800 assuming a completely normal distribution (which isn't quite the case, but it makes a good approximation).

Robust Estimators[edit]

For a normal distribution the relationship between the standard deviation and the interquartile range is roughly: SD = IQR/1.35.

For data that are non-normal, the standard deviation can be a terrible estimator of scale. For example, in the presence of a single outlier, the standard deviation can grossly overestimate the variability of the data. The result is that confidence intervals are too wide and hypothesis tests lack power. In some (or most) fields, it is uncommon for data to be normally distributed and outliers are common.

One robust estimator of scale is the "average absolute deviation", or aad. As the name implies, the mean of the absolute deviations about some estimate of location is used. This method of estimation of scale has the advantage that the contribution of outliers is not squared, as it is in the standard deviation, and therefore outliers contribute less to the estimate. This method has the disadvantage that a single large outlier can completely overwhelm the estimate of scale and give a misleading description of the spread of the data.

Another robust estimator of scale is the "median absolute deviation", or mad. As the name implies, the estimate is calculated as the median of the absolute deviation from an estimate of location. Often, the median of the data is used as the estimate of location, but it is not necessary that this be so. Note that if the data are non-normal, the mean is unlikely to be a good estimate of location.

It is necessary to scale both of these estimators in order for them to be comparable with the standard deviation when the data are normally distributed. It is typical for the terms aad and mad to be used to refer to the scaled version. The unscaled versions are rarely used.

External links[edit]

Other summaries[edit]

Moving Average[edit]

A moving average is used when you want to get a general picture of the trends contained in a data set. The data set of concern is typically a so-called "time series", i.e a set of observations ordered in time. Given such a data set X, with individual data points x_{i}, a 2n+1 point moving average is defined as \bar{x_{i}}=\frac{1}{2n+1}\sum_{k=i-n}^{i+n}x_{k}, and is thus given by taking the average of the 2n points around x_{i}. Doing this on all data points in the set (except the points too close to the edges) generates a new time series that is somewhat smoothed, revealing only the general tendencies of the first time series.

The moving average for many time-based observations is often lagged. That is, we take the 10 -day moving average by looking at the average of the last 10 days. We can make this more exciting (who knew statistics was exciting?) by considering different weights on the 10 days. Perhaps the most recent day should be the most important in our estimate and the value from 10 days ago would be the least important. As long as we have a set of weights that sums to 1, this is an acceptable moving-average. Sometimes the weights are chosen along an exponential curve to make the exponential moving-average.

Displaying Data[edit]

     A single statistic tells only part of a dataset’s story. The mean is one perspective; the median yet another. And when we explore relationships between multiple variables, even more statistics arise. The coefficient estimates in a regression model, the Cochran-Maentel-Haenszel test statistic in partial contingency tables; a multitude of statistics are available to summarize and test data.

     But our ultimate goal in statistics is not to summarize the data, it is to fully understand their complex relationships. A well designed statistical graphic helps us explore, and perhaps understand, these relationships.

     This section will help you let the data speak, so that the world may know its story.

Types of Data Display

  1. Bar_Charts
  2. Histograms
  3. Scatter_Graphs
  4. Box_Plots
  5. Pie_Charts
  6. Comparative_Pie_Charts
  7. Pictograms
  8. Line_Graphs
  9. Frequency_Polygon

External Links

  • [1] "Show me the Numbers" by Stephen Few has a less technical approach to creating graphics. You might want to scan through this book if you are building a library on making graphs.

Statistics | >> Bar Charts

Bar Charts[edit]

The Bar Chart (or Bar Graph) is one of the most common ways of displaying catagorical/qualitative data. Bar Graphs consist of 2 variables, one response (sometimes called "dependent") and one predictor (sometimes called "independent"), arranged on the horizontal and vertical axis of a graph. The relationship of the predictor and response variables is shown by a mark of some sort (usually a rectangular box) from one variable's value to the other's.

To demonstrate we will use the following data(tbl. 3.1.1) representing a hypothetical relationship between a qualitative predictor variable, "Graph Type", and a quantitative response variable, "Votes".


tbl. 3.1.1 - Favourite Graphs

Graph Type Votes
Bar Charts 10
Pie Graphs 2
Histograms 3
Pictograms 8
Comp. Pie Graphs 4
Line Graphs 9
Frequency Polygon 1
Scatter Graphs 5

From this data we can now construct an appropriate graphical representation which, in this case will be a Bar Chart. The graph may be orientated in several ways, of which the vertical chart (fig. 3.1.1) is most common, with the horizontal chart(fig. 3.1.2) also being used often

fig. 3.1.1 - vertical chart
Vertical Bar Chart Example

fig. 3.1.2 - horizontal chart
Horizontal Bar Chart Example

Take note that the height and width of the bars, in the vertical and horizontal Charts, respectfully, are equal to the response variable's corresponding value - "Bar Chart" bar equals the number of votes that the Bar Chart type received in tbl. 3.1.1

Also take note that there is a pronounced amount of space between the individual bars in each of the graphs, this is important in that it help differentiate the Bar Chart graph type from the Histogram graph type discussed in a later section.

External Links[edit]

Histograms[edit]

Histogram of the Michaelson-Morley Speed of Light Data.png

It is often useful to look at the distribution of the data, or the frequency with which certain values fall between pre-set bins of specified sizes. The selection of these bins is up to you, but remember that they should be selected in order to illuminate your data, not obfuscate it.

A histogram is similar to a bar chart. However histograms are used for continuous (as opposed to discrete or qualitative) data. The defining property of a histogram is:

The area of each bar is proportional to the frequency.

If each bin has an equal width, then this can be easily done by plotting frequency on the vertical axis. However histograms can also be drawn with unequal bin sizes, for which one can plot frequency density.

To produce a histogram with equal bin sizes:

  • Select a minimum, a maximum, and a bin size. All three of these are up to you. In the Histogram data used above the minimum is 1, the maximum is 110, and the bin size is 10.
  • Calculate your bins and how many values fall into each of them. For the Histogram data the bins are:
    • 1 ≤ x < 10, 16 values.
    • 10 ≤ x < 20, 4 values.
    • 20 ≤ x < 30, 4 values.
    • 30 ≤ x < 40, 2 values.
    • 40 ≤ x < 50, 2 values.
    • 50 ≤ x < 60, 1 values.
    • 60 ≤ x < 70, 0 values.
    • 70 ≤ x < 80, 0 values.
    • 80 ≤ x < 90, 0 values.
    • 90 ≤ x < 100, 0 value.
    • 100 ≤ x < 110, 0 value.
    • 110 ≤ x < 120, 1 value.
  • Plot the counts you figured out above. Do this using a standard bar plot.

-->

Frequency Density[edit]

Another way of drawing a histogram is to work out the Frequency Density.

Frequency Density
The Frequency Density is the frequency divided by the class width.

The advantage of using frequency density in a histogram is that doesn't matter if there isn't an obvious standard width to use. For all the groups, you would work out the frequency divided by the class width for all of the groups.

External Links

Statistics

Scatter Plots[edit]

Oldfaithful3.png

Scatter Plot is used to show the relationship between 2 numeric variables. It is not useful when comparing discrete variables versus numeric variables. A scatter plot matrix is a collection of pairwise scatter plots of numeric variables.

External Links

Box Plots[edit]

Figure 1. Box plot of data from the Michelson-Morley Experiment

A box plot (also called a box and whisker diagram) is a simple visual representation of key features of a univariate sample.

The box lies on a vertical axis in the range of the sample. Typically, a top to the box is placed at the 1st quartile, the bottom at the third quartile. The width of the box is arbitrary, as there is no x-axis (though see Violin Plots, below).

In between the top and bottom of the box is some representation of central tendency. A common version is to place a horizontal line at the median, dividing the box into two. Additionally, a star or asterisk is placed at the mean value, centered in the box in the horizontal direction.

Another common extension is to the 'box-and-whisker' plot. This adds vertical lines extending from the top and bottom of the plot to for example, the maximum and minimum values, The farthest value within 2 standard deviations above and below the mean. Alternatively, the whiskers could extend to the 2.5 and 97.5 percentiles. Finally, it is common in the box-and-whisker plot to show outliers (however defined) with asterisks at the individual values beyond the ends of the whiskers.

Violin Plots are an extension to box plots using the horizontal information to present more data. They show some estimate of the CDF instead of a box, though the quantiles of the distribution are still shown.

Pie Charts[edit]

A pie chart showing the racial make-up of the US in 2000.
Pie chart of populations of English language-speaking people

A Pie-Chart/Diagram is a graphical device - a circular shape broken into sub-divisions. The sub-divisions are called "sectors", whose areas are proportional to the various parts into which the whole quantity is divided. The sectors may be coloured differently to show the relationship of parts to the whole. A pie diagram is an alternative of the sub-divided bar diagram.

To construct a pie-chart, first we draw a circle of any suitable radius then the whole quantity which is to be divided is equated to 360 degrees. The different parts of the circle in terms of angles are calculated by the following formula.

    Component Value / Whole Quantity * 360

The component parts i.e. sectors have been cut beginning from top in clockwise order.

Note that the percentages in a list may not add up to exactly 100% due to rounding. For example if a person spends a third of their time on each of three activities: 33%, 33% and 33% sums to 99%.

Warning: Pie charts are a very bad way of displaying information. The eye is good at judging linear measures and bad at judging relative areas. A bar chart or dot chart is a preferable way of displaying this type of data.

Cleveland (1985), page 264: "Data that can be shown by pie charts always can be shown by a dot chart. This means that judgements of position along a common scale can be made instead of the less accurate angle judgements." This statement is based on the empirical investigations of Cleveland and McGill as well as investigations by perceptual psychologists.

External Links

Comparative Pie Charts[edit]

A pie chart showing preference of colors by two groups.

The comparative pie charts are very difficult to read and compare if the ratio of the pie chart is not given.

Examine our example of color preference for two different groups. How much work does it take to see that the Blue preference for both groups is the same? First, we have to find blue on each pie, and then remember how many degrees it has. If we did not include the share for blue in the label, then we would probably be approximating the comparison. So, if we use multiple pie charts, we have to expect that comparisions between charts would only be approximate.

What is the most popular color in the left graph? Red. But note, that you have to look at all of the colors and read the label to see which it might be. Also, this author was kind when creating these two graphs because I used the same color for the same object. Imagine the confusion if one had made the most important color get Red in the right-hand chart?

If two shares of data should not be compared via the comparative pie chart, what kind of graph would be preferred? The stacked bar chart is probably the most appropriate for sharing of the total comparisons. Again, exact comparisons cannot be done with graphs and therefore a table may supplement the graph with detailed information.

Pictograms[edit]

Therm.JPG

A pictogram is simply a picture that conveys some statistical information. A very common example is the thermometer graph so common in fund drives. The entire thermometer is the goal (number of dollars that the fund raisers wish to collect. The red stripe (the "mercury") represents the proportion of the goal that has already been collected.

Another example is a picture that represents the gender constitution of a group. Each small picture of a male figure might represent 1,000 men and each small picture of a female figure would, then, represent 1,000 women. A picture consisting of 3 male figures and 4 female figures would indicate that the group is made up of 3,000 men and 4,000 women.

An interesting pictograph is the Chernoff Faces. It is useful for displaying information on cases for which several variables have been recorded. In this kind of plot, each case is represented by a separate picture of a face. The sizes of the various features of each face are used to present the value of each variable. For instance, if blood pressure, high density cholesterol, low density cholesterol, body temperature, height, and weight are recorded for 25 individuals, 25 faces would be displayed. The size of the nose on each face would represent the level of that person's blood pressure. The size of the left eye may represent the level of low density cholesterol while the size of the right eye might represent the level of high density cholesterol. The length of the mouth could represent the person's temperature. The length of the left ear might indicate the person's height and that of the right ear might represent their weight. Of course, a legend would be provided to help the viewer determine what feature relates to which variable. Where it would be difficult to represent the relationship of all 6 variables on a single (6-dimensional) graph, the Chernoff Faces would give a relatively easy to interpret 6-dimensional representation.

Line Graphs[edit]

Basically, a line graph can be, for example, a picture of what happened by/to something (a variable) during a specific time period (also a variable).

On the left side of such a graph usually is as an indication of that "something" in the form of a scale, and at the bottom is an indication of the specific time involved.

Usually a line graph is plotted after a table has been provided showing the relationship between the two variables in the form of pairs. Just as in (x,y) graphs, each of the pairs results in a specific point on the graph, and being a LINE graph these points are connected to one another by a LINE.

Many other line graphs exist; they all CONNECT the points by LINEs, not necessarily straight lines. Sometimes polynomials, for example, are used to describe approximately the basic relationship between the given pairs of variables, and between these points. The higher the degree of the polynomial, the more accurate is the "picture" of that relationship, but the degree of that polynomial must never be higher than n-1, where n is the number of the given points.

See also Graph theory

[[../../Curve fitting|Curve fitting]]

From Wikipedia: Line graph and Curve fitting

External Links

Frequency Polygon[edit]

This is a histogram with an overlaid frequency polygon.

Midpoints of the interval of corresponding rectangle in a histogram are joined together by straight lines. It gives a polygon i.e. a figure with many angles. it is used when two or more sets of data are to be illustrated on the same diagram such as death rates in smokers and non smokers, birth and death rates of a population etc One way to form a frequency polygon is to connect the midpoints at the top of the bars of a histogram ‿with line segments (or a smooth curve). Of course the midpoints themselves could easily be plotted without the histogram and be joined by line segments. Sometimes it is beneficial to show the histogram and frequency polygon together.

Unlike histograms, frequency polygons can be superimposed so as to compare several frequency distributions.

Introduction to Probability[edit]

When throwing two dice, what is the probability that their sum equals seven?

Introduction to probability[edit]

Please note that this page is just a stub, more will be added later.

Why have probability in a statistics textbook?[edit]

Very little in mathematics is truly self contained. Many branches of mathematics touch and interact with one another, and the fields of probability and statistics are no different. A basic understanding of probability is vital in grasping basic statistics, and probability is largely abstract without statistics to determine the "real world" probabilities.

This section is not meant to give a comprehensive lecture in probability, but rather simply touch on the basics that are needed for this class, covering the basics of Bayesian Analysis for those students who are looking for something a little more interesting. This knowledge will be invaluable in attempting to understand the mathematics involved in various Distributions that come later.

Set notion[edit]

A set is a collection of objects. We usually use capital letters to denote sets, for e.g., A is the set of females in this room.

• The members of a set A are called the elements of A. For e.g., Patricia is an element of A (Patricia ∈ A) Patrick is not an element of A (Patrick ∉ A).

• The universal set, U, is the set of all objects under consideration. For e.g., U is the set of all people in this room.

• The null set or empty set, ∅, has no elements. For e.g., the set of males above 2.8m tall in this room is an empty set.

• The complement Ac of a set A is the set of elements in U outside A. I.e. x ∈ Ac iff x ∉ A.

• Let A and B be 2 sets. A is a subset of B if each element of A is also an element of B. Write A ⊂ B. For e.g., The set of females wearing metal frame glasses in this room ⊂ the set of females wearing glasses in this room ⊂ the set of females in this room.

• The intersection A ∩ B of two sets A and B is the set of the common elements. I.e. x ∈ A ∩ B iff x ∈ A and x ∈ B.

• The union A ∪ B of two sets A and B is the set of all elements from A or B. I.e. x ∈ A ∪ B iff x ∈ A or x ∈ B.

Venn diagrams and notation[edit]

A Venn diagram visually models defined events. Each event is expressed with a circle. Events that have outcomes in common will overlap with what is known as the intersection of the events.

A Venn diagram.


Probability[edit]

Probability is connected with some unpredictability. We know what outcomes may occur, but not exactly which one. The set of possible outcomes plays a basic role. We call it the sample space and indicate it by S. Elements of S are called outcomes. In rolling a dice the sample space is S = {1,2,3,4,5,6}. Not only do we speak of the outcomes, but also about events, sets of outcomes. E.g. in rolling a dice we can ask whether the outcome was an even number, which means asking after the event "even" = E = {2,4,6}. In simple situations with a finite number of outcomes, we assign to each outcome s (∈ S) its probability (of occurrence) p(s) (written with a small p), a number between 0 and 1. It is a quite simple function, called the probability function, with the only further property that the total of all the probabilities sum up to 1. Also for events A do we speak of their probability P(A) (written with a capital P), which is simply the total of the probabilities of the outcomes in A. For a fair dice p(s) = 1/6 for each outcome s and P("even") = P(E) = 1/6+1/6+1/6 = 1/2.

The general concept of probability for non-finite sample spaces is a little more complex, although it rests on the same ideas.

Negation[edit]

Negation is a way of saying "not A", hence saying that the complement of A has occurred. Note: The complement of an event A can be expressed as A' or Ac
For example: "What is the probability that a six-sided die will not land on a one?" (five out of six, or p = 0.833)


P[ X' ] = 1 - P[ X ]
Complement of an Event

Or, more colloquially, "the probability of 'not X' together with the probability of 'X' equals one or 100%."

Calculating Probability[edit]

Relative frequency describes the number of successes over the total number of outcomes. For example if a coin is flipped and out of 50 flips 29 are heads then the relative frequency is

\frac{29}{50}


The Union of two events is when you want to know Event A OR Event B.
This is different than "And." "And" is the intersection, "OR" is the union of the events (both events put together).

Union example.jpg
In the above example of events you will notice that...

Event A is a STAR and a DIAMOND.

Event B is a TRIANGLE and a PENTAGON and a STAR
(A ∩ B) = (A and B) = A intersect B is only the STAR
But (A ∪ B) = (A or B) = A Union B is EVERYTHING. The TRIANGLE, PENTAGON, STAR, and DIAMOND
Notice that both event A and Event B have the STAR in common. However, when you list the Union of the events you only list the STAR one time!
Event A = STAR, DIAMOND EVENT B = TRIANGLE, PENTAGON, STAR
When you combine them together you get (STAR + DIAMOND) + (TRIANGLE + PENTAGON + STAR) BUT WAIT!!! STAR is listed two times, so one will need to SUBTRACT the extra STAR from the list.
You should notice that it is the INTERSECTION that is listed TWICE, so you have to subtract the duplicate intersection.

Formula for the Union of Events: P(A ∪ B) = P(A) + P(B) - P(A ∩ B)

Example:
Let P(A) = 0.3 and P(B) = 0.2 and P(A ∩ B) = 0.15. Find P(A ∪ B).
P(A ∪ B) = (0.3) + (0.2) - (0.15) = 0.35

Example:
Let P(A) = 0.3 and P(B) = 0.2 and P(A ∩ B) = 0. Find P(A ∪ B).
Note: Since the intersection of the events is the null set, then you know the events are DISJOINT or MUTUALLY EXCLUSIVE.
P(A ∪ B) = (0.3) + (0.2) - (0) = 0.5

Conjunction[edit]

Disjunction[edit]

Law of total probability[edit]

Generalized case[edit]

Conclusion: putting it all together[edit]

Examples[edit]

Bernoulli Trials[edit]

A lot of experiments just have two possible outcomes, generally referred to as "success" and "failure". If such an experiment is independently repeated we call them (a series of) Bernoulli trials. Usually the probability of success is called p. The repetition may be done in several ways:

  • a fixed number of times (n); as a consequence the observed number of successes is stochastic;
  • until a fixed number of successes (m) is observed; as a consequence the number of experiments is stochastic;

In the first case the number of successes is Binomial distributed with parameters n and p. For n=1 the distribution is also called the Bernoulli distribution. In the second case the number of experiments is Negative Binomial distributed with parameters m and p. For m=1 the distribution is also called the Geometric distribution.

Introductory Bayesian Analysis[edit]

Bayesian analysis is the branch of statistics based on the idea that we have some knowledge in advance about the probabilities that we are interested in, so called a priori probabilities. This might be your degree of belief in a particular event, the results from previous studies, or a general agreed-upon starting value for a probability. The terminology "Bayesian" comes from the Bayesian rule or law, a law about conditional probabilities. The opposite of "Bayesian" is sometimes referred to as "Classical Statistics."

Example[edit]

Consider a box with 3 coins, with probabilities of showing heads respectively 1/4, 1/2 and 3/4. We choose arbitrarily one of the coins. Hence we take 1/3 as the a priori probability P(C_1) of having chosen coin number 1. After 5 throws, in which X=4 times heads came up, it seems less likely that the coin is coin number 1. We calculate the a posteriori probability that the coin is coin number 1, as:

P(C_1|X=4)=\frac{P(X=4|C_1)P(C_1)}{P(X=4)}=\frac{P(X=4|C_1)P(C_1)}{P(X=4|C_1)P(C_1)+P(X=4|C_2)P(C_2)+P(X=4|C_3)P(C_3)}=
\frac{ {5 \choose 4} (\frac 14)^4 \frac 34 \frac 13}
{{5 \choose 4} (\frac 14)^4 \frac 34 \frac 13+{5 \choose 4} (\frac 12)^4 \frac 12 \frac 13+{5 \choose 4} (\frac 34)^4 \frac 14 \frac 13}=

In words:

The probability that the Coin is the first Coin, given that we know heads came up 4 times... Is equal to the probability that heads came up 4 times given we know it's the first coin, times the probability that the coin is the first coin. All divided by the probability that heads comes up 4 times (ignoring which of the three Coins is chosen). The binomial coefficients cancel out as well as all denominators when expanding 1/2 to 2/4. This results in

\frac{3}{3 + 32 + 81}=\frac{3}{116}

In the same way we find:

P(C_2|X=4)=\frac{32}{3 + 32 + 81}=\frac{32}{116}

and

P(C_3|X=4)=\frac{81}{3 + 32 + 81}=\frac{81}{116}.

This shows us that after examining the outcome of the five throws, it is most likely we did choose coin number 3.

Actually for a given result the denominator does not matter, only the relative Probabilities p(C_i) = P(C_i|X=4)/P(X=4) When the result is 3 times heads the Probabilities change in favor of Coin 2 and further as the following table shows:

Heads p(C_1) p(C_2) p(C_3)
5 1 32 243
4 3 32 81
3 9 32 27
2 27 32 9
1 81 32 3
0 243 32 1

Distributions[edit]

How are the results of the latest SAT test? What is the average height of females under 21 in Zambia? How does beer consumption among college students at engineering college compare to college students in liberal arts colleges?

To answer these questions, we would collect data and put them in a form that is easy to summarize, visualize, and discuss. Loosely speaking, the collection and aggregation of data result in a distribution. Distributions are most often in the form of a histogram or a table. That way, we can "see" the data immediately and begin our scientific inquiry.

For example, if we want to know more about students' latest performance on the SAT, we would collect SAT scores from ETS, compile them in a way that is pertinent to us, and then form a distribution of these scores. The result may be a data table or it may be a plot. Regardless, once we "see" the data, we can begin asking more interesting research questions about our data.

The distributions we create often parallel distributions that are mathematically generated. For example, if we obtain the heights of all high school students and plot this data, the graph may resemble a normal distribution, which is generated mathematically. Then, instead of painstakingly collecting heights of all high school students, we could simply use a normal distribution to approximate the heights without sacrificing too much accuracy.

In the study of statistics, we focus on mathematical distributions for the sake of simplicity and relevance to the real-world. Understanding these distributions will enable us to visualize the data easier and build models quicker. However, they cannot and do not replace the work of manual data collection and generating the actual data distribution.

What percentage lie within a certain range? Distributions show what percentage of the data lies within a certain range. So, given a distribution, and a set of values, we can determine the probability that the data will lie within a certain range.

The same data may lead to different conclusions if it is interposed on different distributions. So, it is vital in all statistical analysis for data to be put onto the correct distribution.

Distributions

  1. Probability Distributions
  2. Discrete Distributions
    1. Uniform Distribution
    2. Bernoulli Distribution
    3. Binomial Distribution
    4. Poisson Distribution
    5. Geometric Distribution
    6. Negative Binomial Distribution
    7. Hypergeometric Distribution
  3. Continuous Distributions
    1. Uniform Distribution
    2. Exponential Distribution
    3. Gamma Distribution
    4. Normal Distribution
    5. Chi-Square Distribution
    6. Student-t Distribution
    7. F Distribution
    8. Beta Distribution
    9. Weibull Distribution
    10. Gumbel Distribution

Comparison of Some Distributions[edit]

Some Distributions
Name Notation Formula Symbols Use Continuous/ discrete Notes
Bernoulli f(x)=   p^x (1-p)^{1-x} p
x
2 outcomes Discrete 1 trial
Binomial b(x;n, p)=  {n \choose k} { p^k (1-p)^{n-k}} n trials
k successes
p probability
number of times success
specific probabilities
not random
Discrete
Poisson P(x)=  \frac{e^{- \lambda t} (\lambda t)^x }{ x!}  \mu = \lambda t <br/> \sigma^2= \lambda t outcome/time
outcome/region
Discrete
Hypergeometric h(x;N,n,k) = {{{k \choose x} {{N-k} \choose {n-x}}}\over {N \choose n}} n samples from
N items
k of N items are successes,
N-k are failures
X times sucess occurs
irregard of location
is random
Discrete Without Replacement
Multivariate
Hypergeometric
 h(x_{1},x_{2}...,x_{k};a_{1},a_{2},...a_{k},N,n){{=}}  {a_1 \choose x_1}{a_2 \choose x_2}\dots{a_k \choose x_k}\over {N \choose n} n sample size
N items
k cells  A_1 \dots A_k
each with  a_1 \dots a_k elements
Discrete Without Replacement
Normal  \int_a^b n(x; \mu,\sigma){{=}}  Z {{=}} \frac{x- \mu }\sigma x
 \mu average
 \sigma  std dev
 : \frac{1}{\sigma \sqrt{2 \pi}}   e^{-( x - \mu )^2 /2 \sigma^2} Continuous Z is a random variable with
 \mu {{=}}0 and \sigma^2 {{=}}1
Chi-Square  \chi^2 {{=}}  \frac{(n-1)s^2}{\sigma^2}  S^2 variance of a rand sampp of size n taken from norm pop w/ var  \sigma^2 variances of random sample related to the pop Continuous
Student-t T=  \frac{ \bar{X}- \mu }{S/ \sqrt{n}}  \bar{X} mean of rand samp size n If don't know  \sigma Continuous v=n-1
F F=  \frac{ \sigma_2^2 S_1^2}{ \sigma_1^2 S_2^2} {{=}} \frac{S_1^2}{ S_2^2} Continuous

Discrete Distributions[edit]

'Discrete' data are data that assume certain discrete and quantized values. For example, true-false answers are discrete, because there are only two possible choices. Valve settings such as 'high/medium/low' can be considered as discrete values. As a general rule, if data can be counted in a practical manner, then they can be considered to be discrete.

To demonstrate this, let us consider the population of the world. It is a discrete number because the number of civilians is theoretically countable. But since this is not practicable, statisticians often treat this data as continuous. That is, we think of population as within a range of numbers rather than a single point.

For the curious, the world population is 6,533,596,139 as of August 9, 2006. Please note that statisticians did not arrive at this figure by counting individual residents. They used much smaller samples of the population to estimate the whole. Going back to Chapter 1, this is a great reason to learn statistics - we need only a smaller sample of data to make intelligent descriptions of the entire population!

Discrete distributions result from plotting the frequency distribution of data which is discrete in nature.

General Properties[edit]

Cumulative Distribution Function[edit]

A discrete random variable has a cumulative distribution function that describes the probability that the random variable is below the point. The cumulative distribution must increase towards 1. Depending on the random variable, it may reach one at a finite number, or it may not. The cdf is represented by a capital F.

Probability Mass Function[edit]

A discrete random variable has a probability mass function that describes how likely the random variable is to be at a certain point. The probability mass function must have a total of 1, and sums to the cdf. The pmf is represented by the lowercase f.

Special Values[edit]

The expected value of a discrete variable is \sum_{n_{min}}^{n_{max}} x_i f(x_i)

The expected value of any function of a discrete variable g(X) is \sum_{n_{min}}^{n_{max}} g(x_i)f(x_i)

The variance is equal to E((X-E(X))^2)

External Links

Simulating binomial, hypergeometric, and the Poisson distribution: Discrete Distributions

Discrete Uniform Distribution[edit]

The discrete uniform distribution (not to be confused with the continuous uniform distribution) is where the probability of equally spaced possible values is equal. Mathematically this means that the probability density function is identical for a finite set of evenly spaced points. An example of would be rolling a fair 6-sided die. In this case there are six, equally like probabilities.

One common normalization is to restrict the possible values to be integers and the spacing between possibilities to be 1. In this setup, the only two parameters of the function are the minimum value (a), the maximum value (b). (Some even normalize it more, setting a=1.) Let n=b-a+1 be the number of possibilities. The probability density function is then


f\colon\{a,a+1,\ldots,b-1,b\}\to\R


f\left(x\right)=\frac{1}{n}

Mean[edit]

Let S=\{a,a+1,\ldots,b-1,b\}. The mean (notated as \operatorname{E}[X]) can then be derived as follows:

\operatorname{E}[X] = \sum_{x\in S} x f(x)=\sum^{n-1}_{i=0}\left(\frac{1}{n}(a+i)\right)
\operatorname{E}[X]= {1 \over n}\left( \sum^{n-1}_{i=0} a + \sum^{n-1}_{i=0} i\right)

Remember that in \sum^{m}_{i=0}i = (m^2 + m)/2

\operatorname{E}[X]= {1 \over n}\left( na + {(n-1)^2+(n-1) \over 2} \right)
\operatorname{E}[X]= {2na + n^2-2n+1+n-1 \over 2n}
\operatorname{E}[X]= {2a + n-1 \over 2}
\operatorname{E}[X]= {a + b \over 2}

Variance[edit]

The variance (E[(X-EX)^2]) can be derived:

\operatorname{Var}(X) = \operatorname{E}[(X-\operatorname{E}[X])^2] = \sum_{x\in S}f(x)(x-E[X])^2 = \sum^{n-1}_{i=0}\left(\frac{1}{n}\left((a+i)-{a + b \over 2}\right)^2\right)
\operatorname{Var}(X) = {1 \over n} \sum^{n-1}_{i=0} \left({a+ 2i - b \over 2}\right)^2
\operatorname{Var}(X) = {1 \over 4n} \sum^{n-1}_{i=0} (a^2+ 4ai-2ab+4i^2-4ib + b^2)
\operatorname{Var}(X) = {1 \over 4n} \left[\sum^{n-1}_{i=0} (a^2-2ab + b^2)+ \sum^{n-1}_{i=0} (4ai-4ib)+\sum^{n-1}_{i=0}4i^2\right]
\operatorname{Var}(X) = {1 \over 4n} \left[n(a^2-ab + b^2)+ 4(a-b)\sum^{n-1}_{i=0} i+4\sum^{n-1}_{i=0}i^2\right]

Remember that in \sum^{m}_{i=0}i^2 = m(m+1)(2m+1)/6

\operatorname{Var}(X) = {1 \over 4n} \left[n(b-a)^2+ 4(a-b)[(n-1)n/2]+4[(n-1)n(2n-1)/6]\right]
\operatorname{Var}(X) = {1 \over 4n} \left[n(n-1)^2- 2(n-1)(n-1)n+2(n-1)n(2n-1)/3\right]
\operatorname{Var}(X) = {1 \over 4} \left[-(n-1)^2+2(n-1)(2n-1)/3\right]
\operatorname{Var}(X) = {1 \over 12} \left[-3(n-1)^2+2(n-1)(2n-1)\right]
\operatorname{Var}(X) = {1 \over 12} \left[-3(n^2-2n+1)+2(2n^2-3n+1)\right]
\operatorname{Var}(X) = {n^2-1 \over 12}

Bernoulli Distribution: The coin toss[edit]

Bernoulli
Parameters 0<p<1, p\in\R
Support k=\{0,1\}\,
PMF 
    \begin{cases}
    q=(1-p) & \text{for }k=0 \\ p & \text{for }k=1
    \end{cases}
CDF 
    \begin{cases}
    0 & \text{for }k<0 \\ q & \text{for }0\leq k<1 \\ 1 & \text{for }k\geq 1
    \end{cases}
Mean p\,
Median \begin{cases}
0 & \text{if } q > p\\
0.5 & \text{if } q=p\\
1 & \text{if } q<p
\end{cases}
Mode \begin{cases}
0 & \text{if } q > p\\
0, 1 & \text{if } q=p\\
1 & \text{if } q < p
\end{cases}
Variance p(1-p)\,
Skewness \frac{q-p}{\sqrt{pq}}
Ex. kurtosis \frac{1-6pq}{pq}
Entropy -q\ln(q)-p\ln(p)\,
MGF q+pe^t\,
CF q+pe^{it}\,
PGF q+pz\,
Fisher information  \frac{1}{p(1-p)}

There is no more basic random event than the flipping of a coin. Heads or tails. It's as simple as you can get! The "Bernoulli Trial" refers to a single event which can have one of two possible outcomes with a fixed probability of each occurring. You can describe these events as "yes or no" questions. For example:

  • Will the coin land heads?
  • Will the newborn child be a girl?
  • Are a random person's eyes green?
  • Will a mosquito die after the area was sprayed with insecticide?
  • Will a potential customer decide to buy my product?
  • Will a citizen vote for a specific candidate?
  • Is an employee going to vote pro-union?
  • Will this person be abducted by aliens in their lifetime?

The Bernoulli Distribution has one controlling parameter: the probability of success. A "fair coin" or an experiment where success and failure are equally likely will have a probability of 0.5 (50%). Typically the variable p is used to represent this parameter.

If a random variable X is distributed with a Bernoulli Distribution with a parameter p we write its probability mass function as:

f(x) = \begin{cases}p, & \mbox{if } x = 1\\1-p, & \mbox{if } x = 0\end{cases}\quad 0\leq p \leq 1

Where the event X=1 represents the "yes."

This distribution may seem trivial, but it is still a very important building block in probability. The Binomial distribution extends the Bernoulli distribution to encompass multiple "yes" or "no" cases with a fixed probability. Take a close look at the examples cited above. Some similar questions will be presented in the next section which might give an understanding of how these distributions are related.

Mean[edit]

The mean (E[X]) can be derived:

\operatorname{E}[X] = \sum_i f(x_i) \cdot x_i
\operatorname{E}[X]  = p \cdot 1 + (1-p) \cdot 0
\operatorname{E}[X]= p \,

Variance[edit]

\operatorname{Var}(X) = \operatorname{E}[(X-\operatorname{E}[X])^2] = \sum_i f(x_i)  \cdot (x_i - \operatorname{E}[X])^2
\operatorname{Var}(X)= p \cdot (1-p)^2 + (1-p) \cdot (0-p)^2
\operatorname{Var}(X)= [p(1-p) + p^2](1-p) \,
\operatorname{Var}(X)= p(1-p) \,

External links[edit]

Binomial Distribution[edit]

Probability mass function
Probability mass function for the binomial distribution
Cumulative distribution function
Cumulative distribution function for the binomial distribution
Notation B(n, p)
Parameters nN0 — number of trials
p ∈ [0,1] — success probability in each trial
Support k ∈ { 0, …, n } — number of successes
PMF \textstyle {n \choose k}\, p^k (1-p)^{n-k}
CDF \textstyle I_{1-p}(n - k, 1 + k)
Mean np
Median np⌋ or ⌈np
Mode ⌊(n + 1)p⌋ or ⌊(n + 1)p⌋ − 1
Variance np(1 − p)
Skewness \frac{1-2p}{\sqrt{np(1-p)}}
Ex. kurtosis \frac{1-6p(1-p)}{np(1-p)}
Entropy \frac12 \log_2 \big( 2\pi e\, np(1-p) \big) + O \left( \frac{1}{n} \right)
MGF (1-p + pe^t)^n \!
CF (1-p + pe^{it})^n \!
PGF G(z) = \left[(1-p) + pz\right]^n.
Fisher information  g(p,n) = \frac{n}{p(1-p)}

(continuous parameter only)

Where the Bernoulli Distribution asks the question of "Will this single event succeed?" the Binomial is associated with the question "Out of a given number of trials, how many will succeed?" Some example questions that are modeled with a Binomial distribution are:

  • Out of ten tosses, how many times will this coin land heads?
  • From the children born in a given hospital on a given day, how many of them will be girls?
  • How many students in a given classroom will have green eyes?
  • How many mosquitos, out of a swarm, will die when sprayed with insecticide?

The relation between the Bernoulli and Binomial distributions is intuitive: The Binomial distribution is composed of multiple Bernoulli trials. We conduct n repeated experiments where the probability of success is given by the parameter p and add up the number of successes. This number of successes is represented by the random variable X. The value of X is then between 0 and n.

When a random variable X has a Binomial Distribution with parameters p and n we write it as X ~ Bin(n,p) or X ~ B(n,p) and the probability mass function is given by the equation:

 P\left[X = k\right] = \begin{cases} {n \choose k} p^k \left(1-p\right)^{n-k}\ & 0 \le k \le n \\ 0 & \mbox{otherwise} \end{cases} \quad 0 \leq p \leq 1, \quad n \in \mathbb{N}

where {n \choose k}={n! \over k!(n-k)!}

For a refresher on factorials (n!), go back to the Refresher Course earlier in this wiki book.

An example[edit]

Let's walk through a simple example of the Binomial distribution. We're going to use some pretty small numbers because factorials can be hard to compute. (Few basic calculators even feature them!) We are going to ask five random people if they believe there is life on other planets. We are going to assume in this example that we know 30% of people believe this to be true. We want to ask the question: "How many people will say they believe in extraterrestrial life?" Actually, we want to be more specific than that: "What is the probability that exactly 2 people will say they believe in extraterrestrial life?"

We know all the values that we need to plug into the equation. The number of people asked, n=5. The probability of any given person answering "yes", p=0.3. (Remember, I said that 30% of people believe in life on other planets!) Finally, we're asking for the probability that exactly 2 people answer "yes" so k=2. This yields the equation:

 P \left[X = 2 \right] = {5 \choose 2} \cdot {{0.3^2 \cdot} {\left( 1 - 0.3 \right)^{3}}} = {10} \cdot {{0.3^2} \cdot {\left( 1-0.3 \right)^{3}}} = 0.3087 since {5 \choose 2}={5! \over 2! \cdot 3!}={5 \cdot 4 \cdot 3 \cdot 2 \cdot 1 \over (2 \cdot 1) \cdot (3 \cdot 2 \cdot 1)}={120 \over 12}=10

Here are the probabilities for all the possible values of X. You can get these values by replacing the k=2 in the above equation with all values from 0 to 5.


Value for k Probability f(k)
0 0.16807
1 0.36015
2 0.30870
3 0.13230
4 0.02835
5 0.00243

What can we learn from these results? Well, first of all we'll see that it's just a little more likely that only one person will confess to believing in life on other planets. There's a distinct chance (about 17%) that nobody will believe it, and there's only a 0.24% (a little over 2 in 1000) that all five people will be believers.

Explanation of the equation[edit]

Take the above example. Let's consider each of the five people one by one.

The probability that any one person believes in extraterrestrial life is 30%, or 0.3. So the probability that any two people both believe in extraterrestrial life is 0.3 squared. Similarly, the probability that any one person does not believe in extraterrestrial life is 70%, or 0.7, so the probability that any three people do not believe in extraterrestrial life is 0.7 cubed.

Now, for two out of five people to believe in extraterrestrial life, two conditions must be satisfied: two people believe in extraterrestrial life, and three do not. The probability of two out of five people believing in extraterrestrial life would thus appear to be 0.3 squared (two believers) times 0.7 cubed (three non-believers), or 0.03087.

However, in doing this, we are only considering the case whereby the first two selected people are believers. How do we consider cases such as that in which the third and fifth people are believers, which would also mean a total of two believers out of five?

The answer lies in combinatorics. Bearing in mind that the probability that the first two out of five people believe in extraterrestrial life is 0.03087, we note that there are C(5,2), or 10, ways of selecting a set of two people from out of a set of five, i.e. there are ten ways of considering two people out of the five to be the "first two". This is why we multiply by C(n,k). The probability of having any two of the five people be believers is ten times 0.03087, or 0.3087.

Mean[edit]

The mean can be derived as follow.

\operatorname{E}[X] = \sum_i f(x_i)  \cdot x_i = \sum_{x=0}^n  {n \choose x} p^x \left(1-p\right)^{n-x}  \cdot  x
\operatorname{E}[X] = \sum_{x=0}^n  {n! \over x!(n-x)!} p^x \left(1-p\right)^{n-x} x
\operatorname{E}[X] = {n! \over 0!(n-0)!} p^0 \left(1-p\right)^{n-0}  \cdot 0 + \sum_{x=1}^n  {n! \over x!(n-x)!} p^x \left(1-p\right)^{n-x} x
\operatorname{E}[X] = 0 + \sum_{x=1}^n  {n(n-1)! \over x(x-1)!(n-x)!} p  \cdot p^{x-1} \left(1-p\right)^{n-x} x
\operatorname{E}[X] = np\sum_{x=1}^n  {(n-1)! \over (x-1)!(n-x)!} p^{x-1} \left(1-p\right)^{n-x}

Now let w=x-1 and m=n-1. We see that m-w=n-x. We can now rewrite the summation as

\operatorname{E}[X] = np \left[\sum_{w=0}^m  {m! \over w!(m-w)!} p^{w} \left(1-p\right)^{m-w}\right]

We now see that the summation is the sum over the complete pmf of a binomial random variable distributed Bin(m, p). This is equal to 1 (and can be easily verified using the Binomial theorem). Therefore, we have

\operatorname{E}[X] = np \left[1\right]=np

Variance[edit]

We derive the variance using the following formula:

\operatorname{Var}[X] = \operatorname{E}[X^2] - (\operatorname{E}[X])^2.

We have already calculated E[X] above, so now we will calculate E[X2] and then return to this variance formula:

\operatorname{E}[X^2] = \sum_i f(x_i) \cdot x^2

= \sum_{x=0}^n x^2 \cdot {n\choose x}p^x(1-p)^{n-x}.

We can use our experience gained above in deriving the mean. We use the same definitions of m and w.

\operatorname{E}[X^2] = \sum_{x=0}^n  {n! \over x!(n-x)!} p^x \left(1-p\right)^{n-x} x^2
\operatorname{E}[X^2] = 0 + \sum_{x=1}^n  {n! \over x!(n-x)!} p^x \left(1-p\right)^{n-x} x^2
\operatorname{E}[X^2] = np\sum_{x=1}^n  {(n-1)! \over (x-1)!(n-x)!} p^{x-1} \left(1-p\right)^{n-x}x
\operatorname{E}[X^2] = np \sum_{w=0}^m  {m\choose w} p^{w} \left(1-p\right)^{m-w}(w+1)
\operatorname{E}[X^2] = np \left[\sum_{w=0}^m  {m\choose w} p^{w} \left(1-p\right)^{m-w}w+\sum_{w=0}^m {m\choose w} p^{w} \left(1-p\right)^{m-w} \right]

The first sum is identical in form to the one we calculated in the Mean (above). It sums to mp. The second sum is 1.

\operatorname{E}[X^2] = np \cdot ( mp + 1) = np((n-1)p + 1) = np(np - p + 1).

Using this result in the expression for the variance, along with the Mean (E(X) = np), we get

\operatorname{Var}(X) = \operatorname{E}[X^2] - (\operatorname{E}[X])^2 = np(np - p + 1) - (np)^2 = np(1-p).

External links[edit]

Poisson Distribution[edit]

Poisson
Probability mass function
Plot of the Poisson PMF
The horizontal axis is the index k, the number of occurrences. The function is only defined at integer values of k. The connecting lines are only guides for the eye.
Cumulative distribution function
Plot of the Poisson CDF
The horizontal axis is the index k, the number of occurrences. The CDF is discontinuous at the integers of k and flat everywhere else because a variable that is Poisson distributed only takes on integer values.
Notation \mathrm{Pois}(\lambda)\,
Parameters λ > 0 (real)
Support k ∈ { 0, 1, 2, 3, ... }
PMF \frac{\lambda^k}{k!}\cdot e^{-\lambda}
CDF \frac{\Gamma(\lfloor k+1\rfloor, \lambda)}{\lfloor k\rfloor !}\! --or-- e^{-\lambda} \sum_{i=0}^{\lfloor k\rfloor} \frac{\lambda^i}{i!}\

(for k\ge 0 where \Gamma(x, y)\,\! is the Incomplete gamma function and \lfloor k\rfloor is the floor function)

Mean \lambda\,\!
Median \approx\lfloor\lambda+1/3-0.02/\lambda\rfloor
Mode \lfloor\lambda\rfloor,\,\lceil\lambda\rceil - 1
Variance \lambda\,\!
Skewness \lambda^{-1/2}\,
Ex. kurtosis \lambda^{-1}\,
Entropy \lambda[1\!-\!\log(\lambda)]\!+\!e^{-\lambda}\sum_{k=0}^\infty \frac{\lambda^k\log(k!)}{k!}

(for large \lambda) \frac{1}{2}\log(2 \pi e \lambda) - \frac{1}{12 \lambda} - \frac{1}{24 \lambda^2} -
                     \frac{19}{360 \lambda^3} + O(\frac{1}{\lambda^4})

MGF \exp(\lambda (e^{t}-1))\,
CF \exp(\lambda (e^{it}-1))\,
PGF  \exp(\lambda(z - 1))\,

Any French speaker will notice that "Poisson" means "fish", but really there's nothing fishy about this distribution. It's actually pretty straightforward. The name comes from the mathematician Siméon-Denis Poisson (1781-1840).

The Poisson Distribution is very similar to the Binomial Distribution. We are examining the number of times an event happens. The difference is subtle. Whereas the Binomial Distribution looks at how many times we register a success over a fixed total number of trials, the Poisson Distribution measures how many times a discrete event occurs, over a period of continuous space or time. There isn't a "total" value n. As with the previous sections, let's examine a couple of experiments or questions that might have an underlying Poisson nature.

  • How many pennies will I encounter on my walk home?
  • How many children will be delivered at the hospital today?
  • How many mosquito bites did you get today after having sprayed with insecticide?
  • How many angry phone calls did I get after airing a particularly distasteful political ad?
  • How many products will I sell after airing a new television commercial?
  • How many people, per hour, will cross a picket line into my store?
  • How many alien abduction reports will be filed this year?
  • How many defects will there be per 100 metres of rope sold?

What's a little different about this distribution is that the random variable X which counts the number of events can take on any non-negative integer value. In other words, I could walk home and find no pennies on the street. I could also find one penny. It's also possible (although unlikely, short of an armored-car exploding nearby) that I would find 10 or 100 or 10,000 pennies.

Instead of having a parameter p that represents a component probability like in the Bernoulli and Binomial distributions, this time we have the parameter "lambda" or λ which represents the "average or expected" number of events to happen within our experiment. The probability mass function of the Poisson is given by

P(N=k)=\frac{e^{-\lambda}\lambda^k}{k!}.

An example[edit]

We run a restaurant and our signature dish (which is very expensive) gets ordered on average 4 times per day. What is the probability of having this dish ordered exactly 3 times tomorrow? If we only have the ingredients to prepare 3 of these dishes, what is the probability that it will get sold out and we'll have to turn some orders away?

The probability of having the dish ordered 3 times exactly is given if we set k=3 in the above equation. Remember that we've already determined that we sell on average 4 dishes per day, so λ=4.

P(N=k)=\frac{e^{-\lambda}\lambda^k}{k!} = \frac{e^{-4} 4^3}{3!} = 0.195

Here's a table of the probabilities for all values from k=0..6:

Value for k Probability f(k)
0 0.0183
1 0.0733
2 0.1465
3 0.1954
4 0.1954
5 0.1563
6 0.1042

Now for the big question: Will we run out of food by the end of the day tomorrow? In other words, we're asking if the random variable X>3. In order to compute this we would have to add the probabilities that X=4, X=5, X=6,... all the way to infinity! But wait, there's a better way!

The probability that we run out of food P(X>3) is the same as 1 minus the probability that we don't run out of food, or 1-P(X≤3). So if we total the probability that we sell zero, one, two and three dishes and subtract that from 1, we'll have our answer. So,

1 - P(X≤3) = 1 - ( P(X=0) + P(X=1) + P(X=2) + P(X=3) ) = 1 - 0.4335 = 0.5665

In other words, we have a 56.65% chance of selling out of our wonderful signature dish. I guess crossing our fingers is in order!

Mean[edit]

We calculate the mean as follows:

\operatorname{E}[X] = \sum_i f(x_i) \cdot x_i = \sum^{\infin}_{x=0} \frac{e^{-\lambda}\lambda^x}{x!}x
\operatorname{E}[X] = \frac{e^{-\lambda}\lambda^0}{0!}\cdot 0 + \sum^{\infin}_{x=1} \frac{e^{-\lambda}\lambda^x}{x!}x
\operatorname{E}[X] = 0 + e^{-\lambda} \sum^{\infin}_{x=1} \frac{\lambda \lambda^{x-1}}{(x-1)!}
\operatorname{E}[X] = \lambda e^{-\lambda}\sum^{\infin}_{x=1} \frac{\lambda^{x-1}}{(x-1)!}
\operatorname{E}[X] = \lambda e^{-\lambda}\sum^{\infin}_{x=0} \frac{\lambda^x}{x!}

Remember that \mathrm{e}^{\lambda} = \sum^{\infin}_{x=0} \frac{\lambda^x}{x!}

\operatorname{E}[X] = \lambda e^{-\lambda}e^{\lambda}=\lambda

Variance[edit]

We derive the variance using the following formula:

\operatorname{Var}[X] = \operatorname{E}[X^2] - (\operatorname{E}[X])^2

We have already calculated E[X] above, so now we will calculate E[X2] and then return to this variance formula:

\operatorname{E}[X^2] = \sum_i f(x_i) \cdot x^2
\operatorname{E}[X^2] = \sum^{\infin}_{x=0} \frac{e^{-\lambda}\lambda^x}{x!}x^2
\operatorname{E}[X^2] = 0+\sum^{\infin}_{x=1} \frac{e^{-\lambda}\lambda \lambda^{x-1}}{(x-1)!}x
\operatorname{E}[X^2] = \lambda\sum^{\infin}_{x=0} \frac{e^{-\lambda}\lambda^x}{x!}(x+1)
\operatorname{E}[X^2] = \lambda\left[\sum^{\infin}_{x=0} \frac{e^{-\lambda}\lambda^x}{x!}x+\sum^{\infin}_{x=0} \frac{e^{-\lambda}\lambda^x}{x!}\right]

The first sum is E[X]=λ and the second we also calculated above to be 1.

\operatorname{E}[X^2] = \lambda\left[\lambda+1\right]=\lambda^2+\lambda

Returning to the variance formula we find that

\operatorname{Var}[X] = (\lambda^2+\lambda) - (\lambda)^2=\lambda

External links[edit]

Geometric Distribution[edit]

Geometric
Probability mass function
Geometric pmf.svg
Cumulative distribution function
Geometric cdf.svg
Parameters 0< p \leq 1 success probability (real)
Support k \in \{1,2,3,\dots\}\!
PMF (1 - p)^{k-1}\,p\!
CDF 1-(1 - p)^k\!
Mean \frac{1}{p}\!
Median \left\lceil \frac{-1}{\log_2(1-p)} \right\rceil\! (not unique if -1/\log_2(1-p) is an integer)
Mode 1
Variance \frac{1-p}{p^2}\!
Skewness \frac{2-p}{\sqrt{1-p}}\!
Ex. kurtosis 6+\frac{p^2}{1-p}\!
Entropy \tfrac{-(1-p)\log_2 (1-p) - p \log_2 p}{p}\!
MGF \frac{pe^t}{1-(1-p) e^t}\!,
for t<-\ln(1-p)\!
CF \frac{pe^{it}}{1-(1-p)\,e^{it}}\!

There are two similar distributions with the name "Geometric Distribution".

  • The probability distribution of the number X of Bernoulli trials needed to get one success, supported on the set { 1, 2, 3, ...}
  • The probability distribution of the number Y = X − 1 of failures before the first success, supported on the set { 0, 1, 2, 3, ... }

These two different geometric distributions should not be confused with each other. Often, the name shifted geometric distribution is adopted for the former one. We will use X and Y to refer to distinguish the two.

Shifted[edit]

The shifted Geometric Distribution refers to the probability of the number of times needed to do something until getting a desired result. For example:

  • How many times will I throw a coin until it lands on heads?
  • How many children will I have until I get a girl?
  • How many cards will I draw from a pack until I get a Joker?

Just like the Bernoulli Distribution, the Geometric distribution has one controlling parameter: The probability of success in any independent test.

If a random variable X is distributed with a Geometric Distribution with a parameter p we write its probability mass function as:

P\left( X=i \right) =p\left( 1-p\right)^{i-1}

With a Geometric Distribution it is also pretty easy to calculate the probability of a "more than n times" case. The probability of failing to achieve the wanted result is \left( 1-p\right)^k.

Example: a student comes home from a party in the forest, in which interesting substances were consumed. The student is trying to find the key to his front door, out of a keychain with 10 different keys. What is the probability of the student succeeding in finding the right key in the 4th attempt?

P\left( X=4 \right) =\frac{1}{10}\left( 1-\frac{1}{10}\right)^{4-1}=\frac{1}{10}\left( \frac{9}{10}\right)^{3}=0.0729

Unshifted[edit]

The probability mass function is defined as:

f(x) = p(1-p)^x \, for x \in \{0, 1, 2, \}

Mean[edit]

\operatorname{E}[X] = \sum_i f(x_i) x_i = \sum_0^{\infin} p(1-p)^x x

Let q=1-p

\operatorname{E}[X] = \sum_0^{\infin}(1-q) q^x x
\operatorname{E}[X] = \sum_0^{\infin}(1-q)q q^{x-1} x
\operatorname{E}[X] = (1-q)q\sum_0^{\infin} q^{x-1} x
\operatorname{E}[X] = (1-q)q\sum_0^{\infin} \frac{d}{dq}q^x

We can now interchange the derivative and the sum.

\operatorname{E}[X] = (1-q)q\frac{d}{dq}\sum_0^{\infin} q^x
\operatorname{E}[X] = (1-q)q\frac{d}{dq}{1 \over 1-q}
\operatorname{E}[X] = (1-q)q{1 \over (1-q)^2}
\operatorname{E}[X] = q{1 \over (1-q)}
\operatorname{E}[X] = {(1-p) \over p}

Variance[edit]

We derive the variance using the following formula:

\operatorname{Var}[X] = \operatorname{E}[X^2] - (\operatorname{E}[X])^2

We have already calculated E[X] above, so now we will calculate E[X2] and then return to this variance formula:

\operatorname{E}[X^2] = \sum_i f(x_i) \cdot x^2
\operatorname{E}[X^2] = \sum_0^{\infin} p(1-p)^x x^2

Let q=1-p

\operatorname{E}[X^2] = \sum_0^{\infin} (1-q)q^x x^2

We now manipulate x2 so that we get forms that are easy to handle by the technique used when deriving the mean.

\operatorname{E}[X^2] = (1-q)\sum_0^{\infin} q^x [(x^2-x)+x]
\operatorname{E}[X^2] = (1-q)\left[\sum_0^{\infin} q^x (x^2-x)+\sum_0^{\infin}q^x x\right]
\operatorname{E}[X^2] = (1-q)\left[q^2\sum_0^{\infin} q^{x-2} x(x-1)+q\sum_0^{\infin}q^{x-1} x\right]
\operatorname{E}[X^2] = (1-q)q\left[q\sum_0^{\infin} \frac{d^2}{(dq)^2}q^x+\sum_0^{\infin}\frac{d}{dq}q^x\right]
\operatorname{E}[X^2] = (1-q)q\left[q\frac{d^2}{(dq)^2}\sum_0^{\infin} q^x+\frac{d}{dq}\sum_0^{\infin}q^x\right]
\operatorname{E}[X^2] = (1-q)q\left[q\frac{d^2}{(dq)^2}{1 \over 1-q}+\frac{d}{dq}{1 \over 1-q}\right]
\operatorname{E}[X^2] = (1-q)q\left[q{2 \over (1-q)^3}+{1 \over (1-q)^2}\right]
\operatorname{E}[X^2] = {2q^2 \over (1-q)^2}+{q \over (1-q)}
\operatorname{E}[X^2] = {2q^2 +q(1-q) \over (1-q)^2}
\operatorname{E}[X^2] = {q(q+1) \over (1-q)^2}
\operatorname{E}[X^2] = {(1-p)(2-p) \over p^2}

We then return to the variance formula

\operatorname{Var}[X] = \left[{(1-p)(2-p) \over p^2}\right] - \left({1-p \over p}\right)^2
\operatorname{Var}[X] = {(1-p) \over p^2}

External links[edit]

Negative Binomial Distribution[edit]

Just as the Bernoulli and the Binomial distribution are related in counting the number of successes in 1 or more trials, the Geometric and the Negative Binomial distribution are related in the number of trials needed to get 1 or more successes.

The Negative Binomial distribution refers to the probability of the number of times needed to do something until achieving a fixed number of desired results. For example:

  • How many times will I throw a coin until it lands on heads for the 10th time?
  • How many children will I have when I get my third daughter?
  • How many cards will I have to draw from a pack until I get the second Joker?

Just like the Binomial Distribution, the Negative Binomial distribution has two controlling parameters: the probability of success p in any independent test and the desired number of successes m. If a random variable X has Negative Binomial distribution with parameters p and m, its probability mass function is:

P(X=n) = {n-1 \choose m-1} p^m (1-p)^{n-m} \mbox{, for } n \ge m.

Example[edit]

A travelling salesman goes home if he has sold 3 encyclopedias that day. Some days he sells them quickly. Other days he's out till late in the evening. If on the average he sells an encyclopedia at one out of ten houses he approaches, what is the probability of returning home after having visited only 10 houses?

Answer:

The number of trials X is Negative Binomial distributed with parameters p=0.1 and m=3, hence:

P(X=10) = {9 \choose 2} 0.1^3 0.9^7 = 0.0172186884.

Mean[edit]

The mean can be derived as follows.

\operatorname{E}[X] = \sum_i f(x_i)  \cdot x_i = \sum_{x=0}^\infin  {x+r-1 \choose r-1} p^x (1-p)^r  \cdot  x
\operatorname{E}[X] = {0+r-1 \choose r-1} p^0 \left(1-p\right)^r  \cdot  0 +  \sum_{x=1}^\infin  {x+r-1 \choose r-1} p^x (1-p)^r  \cdot  x
\operatorname{E}[X] = 0 +  \sum_{x=1}^\infin  {(x+r-1)! \over (r-1)!x!} p^x (1-p)^r  \cdot  x
\operatorname{E}[X] = {rp \over 1-p}\sum_{x=1}^\infin  {(x+r-1)! \over r!(x-1)!} p^{x-1} (1-p)^{r+1}

Now let s = r+1 and w=x-1 inside the summation.

\operatorname{E}[X] = {rp \over 1-p}\sum_{w=0}^\infin  {(w+s-1)! \over (s-1)!w!} p^w (1-p)^s
\operatorname{E}[X] = {rp \over 1-p}\sum_{w=0}^\infin  {w+s-1 \choose s-1} p^w (1-p)^s

We see that the summation is the sum over a the complete pmf of a negative binomial random variable distributed NB(s,p), which is 1 (and can be verified by applying Newton's generalized binomial theorem).

\operatorname{E}[X] = {rp \over 1-p}

Variance[edit]

We derive the variance using the following formula:

\operatorname{Var}[X] = \operatorname{E}[X^2] - (\operatorname{E}[X])^2

We have already calculated E[X] above, so now we will calculate E[X2] and then return to this variance formula:

\operatorname{E}[X^2] = \sum_i f(x_i) \cdot x^2

= \sum_{x=0}^\infin {x+r-1 \choose r-1} p^x (1-p)^r \cdot x^2
\operatorname{E}[X^2] = 0+\sum_{x=1}^\infin {x+r-1 \choose r-1} p^x (1-p)^r x^2
\operatorname{E}[X^2] = \sum_{x=1}^\infin {(x+r-1)! \over (r-1)!x!} p^x (1-p)^r x^2
\operatorname{E}[X^2] = {rp \over 1-p}\sum_{x=1}^\infin {(x+r-1)! \over r!(x-1)!} p^{x-1} (1-p)^{r+1} x

Again, let let s = r+1 and w=x-1.

\operatorname{E}[X^2] = {rp \over 1-p}\sum_{w=0}^\infin {(w+s-1)! \over (s-1)!w!} p^w (1-p)^s (w+1)
\operatorname{E}[X^2] = {rp \over 1-p}\sum_{w=0}^\infin {w+s-1 \choose s-1} p^w (1-p)^s (w+1)
\operatorname{E}[X^2] = {rp \over 1-p}\left[\sum_{w=0}^\infin {w+s-1 \choose s-1} p^w (1-p)^s w+\sum_{w=0}^\infin {w+s-1 \choose s-1} p^w (1-p)^s\right]

The first summation is the mean of a negative binomial random variable distributed NB(s,p) and the second summation is the complete sum of that variable's pmf.

\operatorname{E}[X^2] = {rp \over 1-p}\left[{sp \over 1-p}+1\right]
\operatorname{E}[X^2] = {rp(1+rp) \over (1-p)^2}

We now insert values into the original variance formula.

\operatorname{Var}[X] = {rp(1+rp) \over (1-p)^2} - \left({rp \over 1-p}\right)^2
\operatorname{Var}[X] = {rp \over (1-p)^2}

Hypergeometric Distribution[edit]

Hypergeometric
Notation h(k) = {{{m \choose k} {{N-m} \choose {n-k}}}\over {N \choose n}}
Parameters  ???
Support  ???
Unknown type  ???
CDF  ???
Mean  ???
Median  ???
Mode  ???
Unknown type  ???
Skewness  ???
Ex. kurtosis  ???
Entropy  ???
MGF  ???
CF  ???
PGF  ???
Fisher information  ???

The hypergeometric distribution describes the number of successes in a sequence of n draws without replacement from a population of N that contained m total successes.

It's probability mass function is:

f(k) = {{{m \choose k} {{N-m} \choose {n-k}}}\over {N \choose n}}\text{ for all }x \in[0,n]

Technically the support for the function is only where x∈[max(0, n+m-N), min(m, n)]. In situations where this range is not [0,n], f(x)=0 since for k>0, {0\choose k}=0.

Probability Density Function[edit]

We first check to see that f(x) is a valid pmf. This requires that it is non-negative everywhere and that it's total sum is equal to 1. The first condition is obvious. For the second condition we will start with Vandermonde's identity

\sum_{x=0}^n{a \choose x}{b \choose n-x}={a+b \choose n}
\sum_{x=0}^n{{a \choose x}{b \choose n-x} \over {a+b \choose n}}=1

We now see that if a=m and b=N-m that the condition is satisfied.

Mean[edit]

We derive the mean as follows:

\operatorname{E}[X] = \sum^n_{x=0} x \cdot f(x;n,m,N)  = \sum^n_{x=0} x \cdot {{{m \choose x} {{N-m} \choose {n-x}}}\over {N \choose n}}
\operatorname{E}[X] = 0\cdot {{{m \choose 0} {{N-m} \choose {n-0}}}\over {N \choose n}}+\sum^n_{x=1} x \cdot {{{m \choose x} {{N-m} \choose {n-x}}}\over {N \choose n}}

We use the identity  \binom{a}{b} = \frac{a}{b} \binom{a-1}{b-1} in the denominator.

\operatorname{E}[X] = 0+\sum^n_{x=1} x \cdot {{{m \choose x} {{N-m} \choose {n-x}}}\over {{N \over n}{{N-1} \choose {n-1}}}}
\operatorname{E}[X] = {n \over N}\sum^n_{x=1} x \cdot {{{m \choose x} {{N-m} \choose {n-x}}}\over {{N-1} \choose {n-1}}}

Next we use the identity b \binom{a}{b} = a \binom{a-1}{b-1} in the first binomial of the numerator.

\operatorname{E}[X] = {n \over N}\sum^n_{x=1} {m {{m-1 \choose x-1} {{N-m} \choose {n-x}}}\over {{N-1} \choose {n-1}}}

Next, for the variables inside the sum we define corresponding prime variables that are one less. So N′=N−1, m′=m−1, x′=x−1, n′=n-1.

\operatorname{E}[X] = {m n \over N}\sum^{n'}_{x'=0} {{{m' \choose x '} {{N'-m'} \choose {n'-x'}}}\over {{N'} \choose {n'}}}
\operatorname{E}[X] = {m n \over N}\sum^{n'}_{x'=0} f(x';n',m',N')

Now we see that the sum is the total sum over a Hypergeometric pmf with modified parameters. This is equal to 1. Therefore

\operatorname{E}[X] = {n m\over N}


Variance[edit]

We first determine E(X2).

\operatorname{E}[X^2] = \sum_{x=0}^n f(x;n,m,N) \cdot x^2 = \sum_{x=0}^n {{{m \choose x} {{N-m} \choose {n-x}}}\over {N \choose n}} \cdot x^2
\operatorname{E}[X^2] = {{{m \choose 0} {{N-m} \choose {n-0}}}\over {N \choose n}} \cdot 0^2+\sum_{x=1}^n {{{m \choose x} {{N-m} \choose {n-x}}}\over {N \choose n}} \cdot x^2
\operatorname{E}[X^2] = 0+\sum_{x=1}^n {{m {m-1 \choose x-1} {{N-m} \choose {n-x}}}\over {{N \over n}{{N-1} \choose {n-1}}}} \cdot x
\operatorname{E}[X^2] = {mn \over N} \sum_{x=1}^n {{{m-1 \choose x-1} {{N-m} \choose {n-x}}}\over {{{N-1} \choose {n-1}}}} \cdot x

We use the same variable substitution as when deriving the mean.

\operatorname{E}[X^2] = {mn \over N} \sum_{x'=0}^{n'} {{{m' \choose x'} {{N'-m'} \choose {n'-x'}}}\over {{{N'} \choose {n'}}}} (x'+1)
\operatorname{E}[X^2] = {mn \over N} \left[\sum_{x'=0}^{n'} {{{m' \choose x'} {{N'-m'} \choose {n'-x'}}}\over {{{N'} \choose {n'}}}} x'+\sum_{x'=0}^{n'} {{{m' \choose x'} {{N'-m'} \choose {n'-x'}}}\over {{{N'} \choose {n'}}}}\right]

The first sum is the expected value of a hypergeometric random variable with parameteres (n',m',N'). The second sum is the total sum that random variable's pmf.

\operatorname{E}[X^2] = {mn \over N} \left[{n'm' \over N'}+1\right]
\operatorname{E}[X^2] = {mn \over N} \left[{(n-1)(m-1) \over (N-1)}+1\right]={mn \over N} \left[{{(n-1)(m-1) +(N-1)}\over (N-1)}\right]

We then solve for the variance

\operatorname{Var}(X) = \operatorname{E}[X^2]-(\operatorname{E}[X])^2
\operatorname{Var}(X) = {mn \over N} \left[{{(n-1)(m-1) +(N-1)}\over (N-1)}\right]-\left({mn \over N}\right)^2
\operatorname{Var}(X) = {Nmn \over N^2} \left[{{(n-1)(m-1) +(N-1)}\over (N-1)}\right]-{(N-1)(mn)^2 \over (N-1)N^2}
\operatorname{Var}(X) = {nm(N-n)(N-m)\over N^2(N-1)}

Continuous Distributions[edit]

A continuous statistic is a random variable that does not have any points at which there is any distinct probability that the variable will be the corresponding number.

General Properties[edit]

Cumulative Distribution Function[edit]

A continuous random variable, like a discrete random variable, has a cumulative distribution function. Like the one for a discrete random variable, it also increases towards 1. Depending on the random variable, it may reach one at a finite number, or it may not. The cdf is represented by a capital F.

Probability Distribution Function[edit]

Unlike a discrete random variable, a continuous random variable has a probability density function instead of a probability mass function. The difference is that the former must integrate to 1, while the latter must have a total value of 1. The two are very similar, otherwise. The pdf is represented by a lowercase f.

Special Values[edit]

Let R be the set of points of the distribution.

The expected value for a continuous variable X with probability density function f is defined as \int_{R} xf(x)dx.

More generally, the expected value of any continuously transformed variable g(X) with probability density function f is defined as \int_{R} g(x)f(x)dx.

The mean of a continuous or discrete distribution is defined as E[X].

The variance of a continuous or discrete distribution is defined as E[(X-E[X]^2)].

Expectations can also be derived by producing the Moment Generating Function for the distribution in question. This is done by finding the expected value E[\exp(tX)]. Once the Moment Generating Function has been created, each derivative of the function gives a different piece of information about the distribution function.

\frac{d E[\exp(tX)]}{dt} = mean
\frac{d^2 E[\exp(tX)]}{dt^2} = variance
\frac{d^3 E[\exp(tX)]}{dt^3} = skewness
\frac{d^4 E[\exp(tX)]}{dt^4} = kurtosis

Continuous Uniform Distribution[edit]

Uniform
Probability density function
PDF of the uniform probability distribution using the maximum convention at the transition points.
Using maximum convention
Cumulative distribution function
CDF of the uniform probability distribution.
Notation \mathcal{U}(a, b)
Parameters -\infty < a < b < \infty \,
Support x \in [a,b]
PDF \begin{cases}
                  \frac{1}{b - a} & \text{for } x \in [a,b]  \\
                  0               & \text{otherwise}
                \end{cases}
CDF \begin{cases}
                  0               & \text{for } x < a \\
                  \frac{x-a}{b-a} & \text{for } x \in [a,b) \\
                  1               & \text{for } x \ge b
                \end{cases}
Mean \tfrac{1}{2}(a+b)
Median \tfrac{1}{2}(a+b)
Mode any value in [a,b]
Variance \tfrac{1}{12}(b-a)^2
Skewness 0
Ex. kurtosis -\tfrac{6}{5}
Entropy \ln(b-a) \,
MGF \frac{\mathrm{e}^{tb}-\mathrm{e}^{ta}}{t(b-a)}
CF \frac{\mathrm{e}^{itb}-\mathrm{e}^{ita}}{it(b-a)}

The (continuous) uniform distribution, as its name suggests, is a distribution with probability densities that are the same at each point in an interval. In casual terms, the uniform distribution shapes like a rectangle.

Mathematically speaking, the probability density function of the uniform distribution is defined as


f\colon[a,b]\to\R


f\left(x\right)={1 \over {b-a}}

And the cumulative distribution function is:


F\left(x\right)=
\begin{cases}
0, & \mbox{if } x \le a \\
{{x-a} \over {b-a}}, & \mbox{if } a < x < b\\
1, & \mbox{if } x \ge b
\end{cases}

Mean[edit]

We derive the mean as follows.

\operatorname{E}[X] = \int^\infin_{-\infin}xf(x) dx

As the uniform distribution is 0 everywhere but [a, b] we can restrict ourselves that interval

\operatorname{E}[X] = \int^b_a {1 \over {b-a}} x dx
\operatorname{E}[X] = \left.{1 \over (b-a)}{1 \over 2} x^2 \right|^b_a
\operatorname{E}[X] = {1 \over 2(b-a)}\left[ b^2-a^2 \right]
\operatorname{E}[X] = {b+a \over 2}

Variance[edit]

We use the following formula for the variance.

\operatorname{Var}(X) = \operatorname{E}[X^2]-(\operatorname{E}[X])^2
\operatorname{Var}(X) = \left[\int^\infin_{-\infin}f(x) \cdot x^2 dx\right]-\left({b+a \over 2}\right)^2
\operatorname{Var}(X) = \left[\int^b_a {1 \over {b-a}} x^2 dx\right]-{(b+a)^2 \over 4}
\operatorname{Var}(X) = \left. {1 \over {b-a}}{1 \over 3} x^3 \right|^b_a-{(b+a)^2 \over 4}
\operatorname{Var}(X) = {1 \over 3(b-a)}[b^3-a^3] -{(b+a)^2 \over 4}
\operatorname{Var}(X) = {4(b^3-a^3)-3(b+a)^2(b-a) \over 12(b-a)}
\operatorname{Var}(X) = {(b-a)^3 \over 12(b-a)}
\operatorname{Var}(X) = {(b-a)^2 \over 12}

External links[edit]

Normal Distribution[edit]

Probability density function
Probability density function for the normal distribution
The red curve is the standard normal distribution
Cumulative distribution function
Cumulative distribution function for the normal distribution
Notation \mathcal{N}(\mu,\,\sigma^2)
Parameters μR — mean (location)
σ2 > 0 — variance (squared scale)
Support xR
PDF \frac{1}{\sigma\sqrt{2\pi}}\,e^{ -\frac{(x-\mu)^2}{2\sigma^2} }
CDF \frac12\left[1 + \operatorname{erf}\left( \frac{x-\mu}{\sqrt{2\sigma^2}}\right)\right]
Mean μ
Median μ
Mode μ
Variance \sigma^2\,
Skewness 0
Ex. kurtosis 0
Entropy \frac12 \ln(2 \pi e \, \sigma^2)
MGF \exp\{ \mu t + \frac{1}{2}\sigma^2t^2 \}
CF \exp \{ i\mu t - \frac{1}{2}\sigma^2 t^2 \}
Fisher information \begin{pmatrix}1/\sigma^2&0\\0&1/(2\sigma^4)\end{pmatrix}

Normal distribution is without exception the most widely used distribution. It also goes under the name Gaussian distribution. It assumes that the observations are closely clustered around the mean, μ, and this amount is decaying quickly as we go farther away from the mean. The measure of spread is quantified by the variance,  \sigma^2 .

Some examples of applications are:

  • If the average man is 175 cm tall with a variance of 6 cm, what is the probability that a man found at random will be 183 cm tall?
  • If the average man is 175 cm tall with a variance of 6 cm and the average woman is 168 cm tall with a variance of 3cm, what is the probability that the average man will be shorter than the average woman?
  • If cans are assumed to have a variance of 4 grams, what does the average weight need to be in order to ensure that the 99% of all cans have a weight of at least 250 grams?

The density function is:


f_{\mu,\sigma} (x) = \frac{1}{\sigma \sqrt{2 \pi}} e^{-( x - \mu )^2 /2 \sigma^2}

where  - \infty < x < \infty .

and the cumulative distribution function cannot be integrated into a single expression.

Normal distribution with parameters μ and σ is denoted as N(\mu,\sigma). If the rv X is normally distributed with expectation μ and standard deviation σ, one denotes: \!\,X \sim N(\mu,\sigma)

Probability mass function[edit]

To verify that f(x) is a valid pmf we must verify that (1) it is non-negative everywhere, and (2) that the total integral is equal to 1. The first is obvious, so we move on to verify the second.

\int^\infin_{-\infin} \frac{1}{\sigma \sqrt{2 \pi}} e^{-( x - \mu )^2 /2 \sigma^2} dx=\frac{1}{\sigma \sqrt{2 \pi}} \int^\infin_{-\infin}  e^{-( x - \mu )^2 /2 \sigma^2} dx

Now let w={x-\mu \over \sigma \sqrt{2}}. We see that dw={dx \over \sigma \sqrt{2}}.

\frac{1}{\sqrt{\pi}} \int^\infin_{-\infin}  e^{-w^2} dw

Now we use the Gaussian integral that \int_{-\infty}^\infty e^{-w^2}\,dw = \sqrt{\pi}

\frac{1}{\sqrt{ \pi}} \sqrt{\pi}=1

Mean[edit]

We derive the mean as follows

\operatorname{E}[X] = \int^\infin_{-\infin} x \cdot f(x) dx = \int^\infin_{-\infin}x \frac{1}{\sigma \sqrt{2 \pi}} e^{-( x - \mu )^2 /2 \sigma^2} dx
\operatorname{E}[X] = \int^\infin_{-\infin}[(x-\mu)+\mu] \frac{1}{\sigma \sqrt{2 \pi}} e^{-( x - \mu )^2 /2 \sigma^2} dx
\operatorname{E}[X] = \int^\infin_{-\infin}(x-\mu) \frac{1}{\sigma \sqrt{2 \pi}} e^{-( x - \mu )^2 /2 \sigma^2} dx + \int^\infin_{-\infin}\mu \frac{1}{\sigma \sqrt{2 \pi}} e^{-( x - \mu )^2 /2 \sigma^2} dx
\operatorname{E}[X] = \frac{1}{\sigma \sqrt{2 \pi}}(-\sigma^2)\int^\infin_{-\infin}{-x+\mu \over \sigma^2}  e^{-( x - \mu )^2 /2 \sigma^2} dx + \mu\int^\infin_{-\infin} \frac{1}{\sigma \sqrt{2 \pi}} e^{-( x - \mu )^2 /2 \sigma^2} dx

We now see that the right integral is the complete integral over a normal pmf. This is therefore 1.

\operatorname{E}[X] = \frac{1}{\sigma \sqrt{2 \pi}}(-\sigma^2)\left[e^{-( x - \mu )^2 /2 \sigma^2} \right]^\infin_{-\infin} + \mu
\operatorname{E}[X] = \frac{1}{\sigma \sqrt{2 \pi}}(-\sigma^2)[0-0] + \mu
\operatorname{E}[X] = \mu

Variance[edit]

\operatorname{Var}(X) =\operatorname{E}[(X-{E}[X])^2]= \int^\infin_{-\infin} (x-\mu)^2 \cdot f(x) dx = \int^\infin_{-\infin}(x-\mu)^2 \frac{1}{\sigma \sqrt{2 \pi}} e^{- \frac{1}{2} \cdot \left( \frac{x-\mu}{\sigma} \right) ^2} dx

We let w={x-\mu \over \sigma \sqrt{2}}

\operatorname{Var}(X) = \int^\infin_{-\infin}\sigma^2 2w^2 \frac{1}{\sigma \sqrt{2 \pi}} e^{-w^2} \sigma \sqrt{2} dw =  \frac{2\sigma^2}{\sqrt{\pi}} \int^\infin_{-\infin}w \cdot w e^{-w^2} dw

We now use integration by parts with u=w and v=(-1/2)e^(-w^2)

\operatorname{Var}(X) =  \frac{2\sigma^2}{\sqrt{\pi}}  \left(\left[w {-1 \over 2} e^{-w^2}\right]^\infin_{-\infin}-\int^\infin_{-\infin} {-1 \over 2} e^{-w^2} dw\right)

We see that the the bracketed term is zero by L'Hôpital's rule.

\operatorname{Var}(X) =  \frac{2\sigma^2}{\sqrt{\pi}}  \left({1 \over 2}\int^\infin_{-\infin}  e^{-w^2} dw\right)

Now we use the Gaussian integral again

\operatorname{Var}(X) =  \frac{2\sigma^2}{\sqrt{\pi}} {1 \over 2}\sqrt{\pi}= \sigma^2

External links[edit]

Exponential Distribution[edit]

Exponential
Probability density function
Probability density function
Cumulative distribution function
Cumulative distribution function
Parameters λ > 0 rate, or inverse scale
Support x ∈ [0, ∞)
PDF λ e−λx
CDF 1 − e−λx
Mean λ−1
Median λ−1 ln 2
Mode 0
Variance λ−2
Skewness 2
Ex. kurtosis 6
Entropy 1 − ln(λ)
MGF \left(1 - \frac{t}{\lambda}\right)^{-1}\,
CF \left(1 - \frac{it}{\lambda}\right)^{-1}\,

Exponential distribution refers to a statistical distribution used to model the time between independent events that happen at a constant average rate λ. Some examples of this distribution are:

  • The distance between one car passing by after the previous one.
  • The rate at which radioactive particles decay.

For the stochastic variable X, probability distribution function of it is:


f_x (x) =
\begin{cases}
\lambda e^{- \lambda x}, & \mbox{if } x \ge 0 \\
0, & \mbox{if } x < 0
\end{cases}

and the cumulative distribution function is:


F_x (x) =
\begin{cases}
0, & \mbox{if } x < 0 \\
{1 - e^{- \lambda x}}, & \mbox{if } x \ge 0
\end{cases}

Exponential distribution is denoted as  X \in \mbox{Exp(m)} , where m is the average number of events within a given time period. So if m=3 per minute, i.e. there are three events per minute, then λ=1/3, i.e. one event is expected on average to take place every 20 seconds.

Mean[edit]

We derive the mean as follows.

\operatorname{E}[X] = \int^\infin_{-\infin} x \cdot f(x) dx
\operatorname{E}[X] = \int^\infin_{0}x\lambda e^{- \lambda x} dx
\operatorname{E}[X] = \int^\infin_{0}(-x)(-\lambda e^{- \lambda x}) dx

We will use integration by parts with u=−x and v=e−λx. We see that du=-1 and dv=−λe−λx.

\operatorname{E}[X] = \left[-x \cdot e^{- \lambda x}\right]^\infin_{0} - \int^\infin_{0}(e^{- \lambda x})(-1) dx
\operatorname{E}[X] = [0-0] + \left[{-1 \over \lambda}(e^{ -\lambda x})\right]^\infin_{0}
\operatorname{E}[X] = \left[0-{-1 \over \lambda}\right]
\operatorname{E}[X] = {1 \over \lambda}

Variance[edit]

We use the following formula for the variance.

\operatorname{Var}(X) = \operatorname{E}[X^2]-(\operatorname{E}[X])^2
\operatorname{Var}(X) = \int^\infin_{-\infin} x^2 \cdot f(x) dx-\left({1 \over \lambda} \right)^2
\operatorname{Var}(X) = \int^\infin_{0}x^2 \lambda e^{- \lambda x} dx-{1 \over \lambda^2}

We'll use integration by parts with u=−x2 and v=e−λx. From this we have du=−2x and dv=−λe−λx

\operatorname{Var}(X) = \left\{\left[-x^2 \cdot e^{- \lambda x}\right]^\infin_{0} - \int^\infin_{0}(e^{- \lambda x})(-2x) dx\right\}-{1 \over \lambda^2}
\operatorname{Var}(X) = [0-0]+ {2 \over \lambda}\int^\infin_{0}x \lambda e^{- \lambda x} dx -{1 \over \lambda^2}

We see that the integral is just E[X] which we solved for above.

\operatorname{Var}(X) = {2 \over \lambda}{1 \over \lambda} -{1 \over \lambda^2}
\operatorname{Var}(X) = {1 \over \lambda^2}

External links[edit]

Gamma Distribution[edit]

Gamma
Probability density function
Probability density plots of gamma distributions
Cumulative distribution function
Cumulative distribution plots of gamma distributions
Parameters
Support \scriptstyle x \;\in\; (0,\, \infty)\!
PDF \scriptstyle \frac{1}{\Gamma(k) \theta^k} x^{k \,-\, 1} e^{-\frac{x}{\theta}}\,\!
CDF \scriptstyle \frac{1}{\Gamma(k)} \gamma\left(k,\, \frac{x}{\theta}\right)\!
Mean \scriptstyle \operatorname{E}[ X] = k \theta \!
\scriptstyle \operatorname{E}[\ln X] = \psi(k) +\ln(\theta)\!
(see digamma function)
Median No simple closed form
Mode \scriptstyle (k \,-\, 1)\theta \text{ for } k \;>\; 1\,\!
Variance \scriptstyle\operatorname{Var}[ X] = k \theta^2\,\!
\scriptstyle\operatorname{Var}[\ln X] = \psi_1(k)\!
(see trigamma function )
Skewness \scriptstyle \frac{2}{\sqrt{k}}\,\!
Ex. kurtosis \scriptstyle \frac{6}{k}\,\!
Entropy \scriptstyle \begin{align}
                      \scriptstyle k &\scriptstyle \,+\, \ln\theta \,+\, \ln[\Gamma(k)]\\
                      \scriptstyle   &\scriptstyle \,+\, (1 \,-\, k)\psi(k)
                    \end{align}

The Gamma distribution is very important for technical reasons, since it is the parent of the exponential distribution and can explain many other distributions.

The probability distribution function is:


f_x (x) =
\begin{cases}
\frac{1}{a^p \Gamma (p)} x^{p-1} e^{-x/a}, & \mbox{if } x \ge 0 \\
0, & \mbox{if } x < 0
\end{cases}\quad a,p >0

Where  \Gamma(p) = \int_0^\infty  t^{p-1} e^{-t}\,dt\, is the Gamma function. The cumulative distribution function cannot be found unless p=1, in which case the Gamma distribution becomes the exponential distribution. The Gamma distribution of the stochastic variable X is denoted as  X \in \Gamma (p,a) .

Alternatively, the gamma distribution can be parameterized in terms of a shape parameter \alpha = k and an inverse scale parameter \beta = 1/\theta, called a rate parameter:

 g(x;\alpha,\beta) = K x^{\alpha-1}  e^{-\beta\,x}   \ \mathrm{for}\ x > 0 \,\!.

where the K constant can be calculated setting the integral of the density function as 1:


\int_{-\infty}^{+\infty}g(x;\alpha,\beta) \mathrm{d}t \, = \int_{0}^{+\infty} K x^{\alpha-1}  e^{-\beta\,x}  \mathrm{d}x \, = 1

following:


K \int_{0}^{+\infty} x^{\alpha-1}  e^{-\beta\,x}  \mathrm{d}x \, = 1

K = \frac{1}{\int_{0}^{+\infty} x^{\alpha-1}  e^{-\beta\,x}  \mathrm{d}x}

and, with change of variable  y = \beta x  :


\begin{align}
K &= \frac{1}{\int_{0}^{+\infty} \frac{y^{\alpha-1}}{\beta^{\alpha - 1}}  e^{-y}  \frac{\mathrm{d}y}{\beta}} \\

&= \frac{1}{\frac{1}{\beta^{\alpha}}\int_{0}^{+\infty} y^{\alpha-1}  e^{-y} \mathrm{d}y} \\

&= \frac{\beta^{\alpha}}{\int_{0}^{+\infty} y^{\alpha-1}  e^{-y}  \mathrm{d}y} \\

&= \frac{\beta^{\alpha}}{\Gamma(\alpha)}
\end{align}

following:

 g(x;\alpha,\beta) = x^{\alpha-1}  \frac{\beta^{\alpha} \, e^{-\beta\,x} }{\Gamma(\alpha)}  \ \mathrm{for}\ x > 0 \,\!.

Probability Density Function[edit]

We first check that the total integral of the probability density function is 1.

\int^\infin_{-\infin}\frac{1}{a^p \Gamma (p)} x^{p-1} e^{-x/a}dx

Now we let y=x/a which means that dy=dx/a

\frac{1}{ \Gamma (p)} \int^\infin_{0} y^{p-1} e^{-y}dy
\frac{1}{ \Gamma (p)} \Gamma (p)=1

Mean[edit]

\operatorname{E}[X]=\int^\infin_{-\infin}x \cdot \frac{1}{a^p \Gamma (p)} x^{p-1} e^{-x/a}dx

Now we let y=x/a which means that dy=dx/a.

\operatorname{E}[X]=\int^\infin_{0}ay \cdot \frac{1}{\Gamma (p)} y^{p-1} e^{-y}dy
\operatorname{E}[X]=\frac{a}{\Gamma (p)}\int^\infin_{0}y^{p} e^{-y}dy
\operatorname{E}[X]=\frac{a}{\Gamma (p)}\Gamma (p+1)

We now use the fact that \Gamma (z+1)=z\Gamma (z)

\operatorname{E}[X]=\frac{a}{\Gamma (p)}p\Gamma (p)=ap

Variance[edit]

We first calculate E[X^2]

\operatorname{E}[X^2]=\int^\infin_{-\infin}x^2 \cdot \frac{1}{a^p \Gamma (p)} x^{p-1} e^{-x/a}dx

Now we let y=x/a which means that dy=dx/a.

\operatorname{E}[X^2]=\int^\infin_0 a^2 y^2 \cdot \frac{1}{a \Gamma (p)} y^{p-1} e^{-y}ady
\operatorname{E}[X^2]=\frac{a^2}{ \Gamma (p)}\int^\infin_0  y^{p+1} e^{-y}dy
\operatorname{E}[X^2]=\frac{a^2}{ \Gamma (p)}\Gamma (p+2) =pa^2(p+1)

Now we use calculate the variance

\operatorname{Var}(X)=\operatorname{E}[X^2]-(\operatorname{E}[X])^2
\operatorname{Var}(X)=pa^2(p+1)-(ap)^2=pa^2

External links[edit]

F Distribution[edit]

Fisher-Snedecor
Probability density function
F distributionPDF.png
Cumulative distribution function
F distributionCDF.png
Parameters d1, d2 > 0 deg. of freedom
Support x ∈ [0, +∞)
PDF \frac{\sqrt{\frac{(d_1\,x)^{d_1}\,\,d_2^{d_2}}
{(d_1\,x+d_2)^{d_1+d_2}}}}
{x\,\mathrm{B}\!\left(\frac{d_1}{2},\frac{d_2}{2}\right)}\!
CDF I_{\frac{d_1 x}{d_1 x + d_2}} \left(\tfrac{d_1}{2}, \tfrac{d_2}{2} \right)
Mean \frac{d_2}{d_2-2}\!
for d2 > 2
Mode \frac{d_1-2}{d_1}\;\frac{d_2}{d_2+2}\!
for d1 > 2
Variance \frac{2\,d_2^2\,(d_1+d_2-2)}{d_1 (d_2-2)^2 (d_2-4)}\!
for d2 > 4
Skewness \frac{(2 d_1 + d_2 - 2) \sqrt{8 (d_2-4)}}{(d_2-6) \sqrt{d_1 (d_1 + d_2 -2)}}\!
for d2 > 6
Ex. kurtosis see text
MGF does not exist, raw moments defined in text and in [1][2]
CF see text

Named after Sir Ronald Fisher, who developed the F distribution for use in determining ANOVA critical values. The cutoff values in an F table are found using three variables- ANOVA numerator degrees of freedom, ANOVA denominator degrees of freedom, and significance level.

ANOVA is an abbreviation of analysis of variance. It compares the size of the variance between two different samples. This is done by dividing the larger variance over the smaller variance. The formula of the F statistic is:


F(r_1, r_2) = \frac{\chi_{r1} ^2 /r_1}{\chi_{r2} ^2 /r_2}

where  \chi_{r1}^2 and  \chi_{r2}^2 are the chi-square statistics of sample one and two respectively, and  r1 \mbox{and } r2 are their degrees of freedom, i.e. the number of observations.

One example could be if you want to compare apples that look alike but are from different trees and have different sizes. You want to investigate whether they have the same variance of the weight on average.

There are three apples from the first tree that weigh 110, 121 and 143 grams respectively, and four from the other which weigh 88, 93, 105 and 124 grams respectively. The mean and variance of the first sample are 124.67 and 16.80 respectively, and of the second sample 102.50 and 16.01. The chi-square statistic of the first sample is


\frac{110-124.67}{16.80^2} + \frac{121-124.67}{16.80^2} + \frac{143-124.67}{16.80^2} = 2.00
,

and for the second sample


\frac{88-102.50}{16.01^2} + \frac{93-102.50}{16.01^2} + \frac{105-102.50}{16.01^2} + \frac{124-102.50}{16.01^2} = 3.00
.

The F statistic is now F = \frac{3/4}{2/3} = 1.125. The Chi-square statistic divided by degrees of freedom appears on the nominator for the second sample because it was larger than that of the first sample.

The critical value of the F distribution for 4 degrees of freedom. in the nominator and 3 degrees of freedom in the denominator, i.e. F(f1=4, f2=3) is 9.12 at a 5% level of confidence. Since the test statistic 1.125 is smaller than the critical value, we cannot reject the null hypothesis that they have the same variance. The conclusion is that they have the same variance.

External links[edit]

Chi-square Distribution[edit]

Probability density function
Chi-square pdf.svg
Cumulative distribution function
325px
Notation \chi^2(k)\! or \chi^2_k\!
Parameters k \in \mathbb{N}~~ (known as "degrees of freedom")
Support x ∈ [0, +∞)
PDF \frac{1}{2^{\frac{k}{2}}\Gamma\left(\frac{k}{2}\right)}\; x^{\frac{k}{2}-1} e^{-\frac{x}{2}}\,
CDF \frac{1}{\Gamma\left(\frac{k}{2}\right)}\;\gamma\left(\frac{k}{2},\,\frac{x}{2}\right)
Mean k
Median \approx k\bigg(1-\frac{2}{9k}\bigg)^3
Mode max{ k − 2, 0 }
Variance 2k
Skewness \scriptstyle\sqrt{8/k}\,
Ex. kurtosis 12 / k
Entropy \frac{k}{2}\!+\!\ln(2\Gamma(k/2))\!+\!(1\!-\!k/2)\psi(k/2)
MGF (1 − 2 t)k/2   for  t  < ½
CF (1 − 2 it)k/2      [3]

Chi-square distribution is related to normal distribution. A chi-square statistic is the sum of a number of independent and standard normal random variables.

Assume that we have n number of random variables Z, that are normally distributed. Therefore, we can write  Z \in N(0,1) . If we square Z such that  Z^2 , then we get the chi-square distribution  Z^2 \in \chi_{1}^2 . If we sum n number of  \chi_{1}^2 , we can write


Y = Z_1^2 + Z_2^2 + ... + Z_n^2 \in \chi_{n}^2
.

One example could be that we want to know whether the weight of a set of eight apples is normally distributed. Chi-square distribution can be used to test for this. Assume that the apples weigh 88, 93, 110, 76, 78, 121, 92 and 86 grams, and we have knowledge of the mean and the standard deviation weight of all apples. We obtain the normally distributed Z values by subtracting the mean weight (93) and divide by the standard deviation (15.41). For example, the first apple has got  Z_1 = \frac{88-93}{15.41} = -0.3245 using four decimal points. Square all the Z values, then taking the sum yields a Chi-squared distributed random variable with mean 8 and variance 16.

Now when we have the value of the chi-square statistic Y, we compare it to the critical value of the chi-square distribution at n = 8 degrees of freedom and 95% level of significance which can found in a Chi-square statistical table. The null hypothesis is that the sample of apples is normally distributed. It is rejected if the value of the test statistic is higher than the critical value.

The chi-square distribution is a special case of the gamma distribution, where a=2 and p=k/2. The probability density function is:

\frac{1}{2^{k/2}\Gamma(k/2)}\; x^{k/2-1} e^{-x/2}\quad x\geq 0,\,k \in [1,2,...]

Summary statistics[edit]

The mean of a chi-squared is k

The variance of a chi-squared is 2k

For the proof of these, see the gamma distribution.

External links[edit]

Student-t Distribution[edit]

Student’s t
Probability density function
Student t pdf.svg
Cumulative distribution function
Student t cdf.svg
Parameters ν > 0 degrees of freedom (real)
Support x ∈ (−∞; +∞)
PDF \textstyle\frac{\Gamma \left(\frac{\nu+1}{2} \right)} {\sqrt{\nu\pi}\,\Gamma \left(\frac{\nu}{2} \right)} \left(1+\frac{x^2}{\nu} \right)^{-\frac{\nu+1}{2}}\!
CDF \begin{matrix}
     \frac{1}{2} + x \Gamma \left( \frac{\nu+1}{2} \right)  \cdot\\[0.5em]
     \frac{\,_2F_1 \left ( \frac{1}{2},\frac{\nu+1}{2};\frac{3}{2};
           -\frac{x^2}{\nu} \right)}
     {\sqrt{\pi\nu}\,\Gamma \left(\frac{\nu}{2}\right)}
     \end{matrix}
where 2F1 is the hypergeometric function
Mean 0 for ν > 1, otherwise undefined
Median 0
Mode 0
Variance \textstyle\frac{\nu}{\nu-2} for ν > 2, ∞ for 1 < ν ≤ 2, otherwise undefined
Skewness 0 for ν > 3, otherwise undefined
Ex. kurtosis \textstyle\frac{6}{\nu-4} for ν > 4, ∞ for 2 < ν ≤ 4, otherwise undefined
Entropy ...
MGF undefined
CF \textstyle\frac{K_{\nu/2} \left(\sqrt{\nu}|t|)(\sqrt{\nu}|t| \right)^{\nu/2}}{\Gamma(\nu/2)2^{\nu/2-1}} for ν > 0

Student t-distribution (or just t-distribution for short) is derived from the chi-square and normal distributions. We divide the standard normally distributed value of one variable over the root of a chi-square value over its r degrees of freedom. Mathematically, this appears as:


t = \frac{\mbox{Z}}{ \sqrt{ \chi_{r}^2 /r }}

where  Z = \frac{X - \bar{X}}{\sigma} and  \chi_{r}^2 = \chi_{r_1}^2 + ... + \chi_{r_n}^2 .

External links[edit]

Testing Statistical Hypothesis[edit]

Two examples of how the means of two distributions may be different, leading to two different statistical hypotheses
Equal distributions, but different means.

There are many different tests for the many different kinds of data. A way to get started is to understand what kind of data you have. Are the variables quantitative or qualitative? Certain tests are for certain types of data depending on the size, distribution or scale. Also, it is important to understand how samples of data can differ. The 3 primary characteristics of quantitative data are: central tendency, spread, and shape.

When most people "test" quantitative data, they tend to do tests for central tendency. Why? Well, let's say you had 2 sets of data and you wanted to see if they were different from each other. One way to test this would be to test to see if their central tendency (their means for example) differ.

Imagine two symmetric, bell shaped curves with a vertical line drawn directly in the middle of each, as shown here. If one sample was a lot different than another (a lot higher in values,etc.) then the means would be different typically. So when testing to see if two samples are different, usually two means are compared.

Two medians (another measure of central tendency) can be compared also. Or perhaps one wishes to test two samples to see if they have the same spread or variation. Because statistics of central tendency, spread, etc. follow different distributions - different testing procedures must be followed and utilized.

In the end, most folks summarize the result of a hypothesis test into one particular value - the p-value. If the p-value is smaller than the level of significance (usually \alpha=5%, but even lower in other fields of science i.e. Medicine) then you reject the null-hypothesis, but this does not mean you accept the alternative hypothesis. The p-value is essentially the probability of obtaining a test statistic at least as extreme as the one observed. If the p-value is greater than the level of significance you fail to reject the null-hypothesis, but this does not mean that the null-hypothesis is correct.

Purpose of Statistical Tests[edit]

Purpose of Statistical Tests[edit]

In general, the purpose of statistical tests is to determine whether some hypothesis is extremely unlikely given observed data.

There are two common philosophical approaches to such tests, significance testing (due to Fisher) and hypothesis testing (due to Neyman and Pearson).

Significance testing aims to quantify evidence against a particular hypothesis being true. We can think of it as testing to guide research. We believe a certain statement may be true and want to work out whether it is worth investing time investigating it. Therefore, we look at the opposite of this statement. If it is quite likely then further study would seem to not make sense. However if it is extremely unlikely then further study would make sense.

A concrete example of this might be in drugs testing. We have a number of drugs that we want to test and only limited time, so we look at the hypothesis that an individual drug has no positive effect whatsoever, and only look further if this is unlikley.

Hypothesis testing rather looks at evidence for a particular hypothesis being true. We can think of this as a guide to making a decision. We need to make a decision soon, and suspect that a given statement is true. Thus we see how unlikely we are to be wrong, and if we are sufficiently unlikely to be wrong we can assume that this statement is true. Often this decision is final and cannot be changed.

Statisticians often overlook these differences and incorrectly treat the terms "significance test" and "hypothesis test" as though they are interchangeable.

A data analyst frequently wants to know whether there is a difference between two sets of data, and whether that difference is likely to occur due to random fluctuations, or is instead unusual enough that random fluctuations rarely cause such differences.

In particular, frequently we wish to know something about the average (or mean), or about the variability (as measured by variance or standard deviation).

Statistical tests are carried out by first making some assumption, called the Null Hypothesis, and then determining whether the data observed is unlikely to occur given that assumption. If the probability of seeing the observed data is small enough under the assumed Null Hypothesis, then the Null Hypothesis is rejected.

A simple example might help. We wish to determine if men and women are the same height on average. We select and measure 20 women and 20 men. We assume the Null Hypothesis that there is no difference between the average value of heights for men vs. women. We can then test using the t-test to determine whether our sample of 40 heights would be unlikely to occur given this assumption. The basic idea is to assume heights are normally distributed, and to assume that the means and standard deviations are the same for women and for men. Then we calculate the average of our 20 men, and of our 20 women, we also calculate the sample standard deviation for each. Then using the t-test of two means with 40-2 = 38 degrees of freedom we can determine whether the difference in heights between the sample of men and the sample of women is sufficiently large to make it unlikely that they both came from the same normal population.

Different Types of Tests[edit]

A statistical test is always about one or more parameters of the concerned population (distribution). The appropiate test depends on the type of null and alternative hypothesis about this (these) parameter(s) and the available information from the sample.

Example[edit]

It is conjectured that British children gain more weight lately. Hence the population mean μ of the weight X of children of let's say 12 years of age is the parameter at stake. In the recent past the mean weight of this group of children turned out to be 45 kg. Hence the null hypothesis (of no change) is:

\,H_0: \mu = 45.

As we suspect a gain in weight, the alternative hypothesis is:

\,H_1: \mu > 45.

A random sample of 100 children shows an average weight of 47 kg with a standard deviation of 8 kg.

Because it is reasonable to assume that the weights are normally distributed, the appropriate test will be a t-test, with test statistic:

T = \frac{\bar{X} - 45}{S}\sqrt{100}.

Under the null hypothesis T will be Student distributed with 99 degrees of freedom, which means approximately standard normally distributed.

The null hypothesis will be rejected for large values of T. For this sample the value t of T is:

t = \frac{47 - 45}{8}\sqrt{100} = 2.5.

Is this a large value? That depends partly on our demands. The so called p-value of the observed value t is:

p=P(T\ge t; H_0)= P(T\ge 2.5; H_0) \approx P(Z\ge 2.5) <0.01 ,

in which Z stands for a standard normally distributed random variable.

If we are not too critical this is small enough, so reason to reject the null hypothesis and to assume our conjecture to be true.

Now suppose we have lost the individual data, but still know that the maximum weight in the sample was 68 kg. It is not possible then to use the t-test, and instead we have to use a test based on the statistic max(X).

It might also be the case that our assumption on the distribution of the weight is questionable. To avoid discussion we may use a distribution free test instead of a t-test.

A statistical test begins with a hypothesis; the form of that hypothesis determines the type(s) of test(s) that can be used. In some cases, only one is appropriate; in others, one may have some choice.

For example: if the hypothesis concerns the value of a single population mean (\mu ), then a one sample test for mean is indicated. Whether the z-test or t-test should be used depends on other factors (each test has its own requirements).

A complete listing of the conditions under which each type of test is indicated is probably beyond the scope of this work; refer to the sections for the various types of tests for more information about the indications and requirements for each test.

z Test for a Single Mean[edit]

The Null Hypothesis should be an assumption concerning the value of the population mean. The data should consist of a single sample of quantitative data from the population.

Requirements[edit]

The sample should be drawn from a population from which the Standard Deviation (or Variance) is known. Also, the measured variable (typically listed as x-\bar x is the sample statistic) should have a Normal Distribution.

Note that if the distribution of the variable in the population is non-normal (or unknown), the z-test can still be used for approximate results, provided the sample size is sufficiently large. Historically, sample sizes of at least 30 have been considered sufficiently large; reality is (of course) much more complicated, but this rule of thumb is still in use in many textbooks.

If the population Standard Deviation is unknown, then a z-test is typically not appropriate. However, when the sample size is large, the sample standard deviation can be used as an estimate of the population standard deviation, and a z-test can provide approximate results.

Definitions of Terms[edit]

\mu = Population Mean
\sigma_x = Population Standard Deviation
\bar x = Sample Mean
\sigma_{\bar x} = Sample Standard Deviation
N = Sample Population

Procedure[edit]

  • The Null Hypothesis:

This is a statement of no change or no effect; often, we are looking for evidence that this statement is no longer true.

H0 : μ = μ0
  • The Alternate Hypothesis:

This is a statement of inequality; we are looking for evidence that this statement is true.

H1 : μ < μ0 or
H1 : μ > μ0 or
H1 : μ ≠ μ0
  • The Test Statistic:
z=\frac{\bar x -\mu _0}{\sigma / \sqrt{n}}
  • The Significance (p-value)

Calculate the probability of observing a value of z (from a Standard Normal Distribution) using the Alternate Hypothesis to indicate the direction in which the area under the Probability Density Function is to be calculated. This is the Attained Significance, or p-value.

Note that some (older) methods first chose a Level Of Significance, which was then translated into a value of z. This made more sense (and was easier!) in the days before computers and graphics calculators.

  • Decision

The Attained Significance represents the probability of obtaining a test statistic as extreme, or more extreme, than ours - if the null hypothesis is true.

If the Attained Significance (p-value) is sufficiently low, then this indicates that our test statistic is unusual (rare) - we usually take this as evidence that the null hypothesis is in error. In this case, we reject the null hypothesis.

If the p-value is large, then this indicates that the test statistic is usual (common) - we take this as a lack of evidence against the null hypothesis. In this case, we fail to reject the null hypothesis.

It is common to use 5% as the dividing line between the common and the unusual; again, reality is more complicated. Sometimes a lower level of uncertainty must be chosen should the consequences of error results in a decision that can injure or kill people or do great economic harm. We would more likely tolerate a drug that kills 5% of patients with a terminal cancer but cures 95% of all patients, but we would hardly tolerate a cosmetic that disfigures 5% of those who use it.

Worked Examples[edit]

Are The Kids Above Average?[edit]

Scores on a certain test of mathematical aptitude have mean μ = 50 and standard deviation σ = 10. An amateur researcher believes that the students in his area are brighter than average, and wants to test his theory.

The researcher has obtained a random sample of 45 scores for students in his area. The mean score for this sample is 52.

Does the researcher have evidence to support his belief?

The null hypothesis is that there is no difference, and that the students in his area are no different than those in the general population; thus,

H0 : μ = 50

(where μ represents the mean score for students in his area)

He is looking for evidence that the students in his area are above average; thus, the alternate hypothesis is

H1 : μ > 50

Since the hypothesis concerns a single population mean, a z-test is indicated. The sample size is fairly large (greater than 30), and the standard deviation is known, so a z-test is appropriate.

z=\frac{\bar x -\mu _0}{\sigma / \sqrt{n}} =\frac{52-50}{10/ \sqrt{45}}=1.3416

We now find the area under the Normal Distribution to the right of z = 1.3416 (to the right, since the alternate hypothesis is to the right). This can be done with a table of values, or software- I get a value of 0.0899.

If the null hypothesis is true (and these students are no better than the general population), then the probability of obtaining a sample mean of 52 or higher is 8.99%. This occurs fairly frequently (using the 5% rule), so it does not seem unusual. I fail to reject the null hypothesis (at the 5% level).

It appears that the evidence does not support the researcher's belief.

Is The Machine Working Correctly?[edit]

Sue is in charge of Quality Control at a bottling facility. Currently, she is checking the operation of a machine that is supposed to deliver 355 mL of liquid into an aluminum can. If the machine delivers too little, then the local Regulatory Agency may fine the company. If the machine delivers too much, then the company may lose money. For these reasons, Sue is looking for any evidence that the amount delivered by the machine is different from 355 mL.

During her investigation, Sue obtains a random sample of 10 cans, and measures the following volumes:

355.02 355.47 353.01 355.93 356.66 355.98 353.74 354.96 353.81 355.79

The machine's specifications claim that the amount of liquid delivered varies according to a normal distribution, with mean μ = 355 mL and standard deviation σ = 0.05 mL.

Do the data suggest that the machine is operating correctly?

The null hypothesis is that the machine is operating according to its specifications; thus

H0 : μ = 355

(where μ is the mean volume delivered by the machine)

Sue is looking for evidence of any difference; thus, the alternate hypothesis is

H1 : μ ≠ 355

Since the hypothesis concerns a single population mean, a z-test is indicated. The population follows a normal distribution, and the standard deviation is known, so a z-test is appropriate.

In order to calculate the test statistic (z), we must first find the sample mean from the data. Use a calculator or computer to find that \bar x = 355.037.

z=\frac{\bar x -\mu _0}{\sigma / \sqrt{n}} =\frac{355.037-355}{0.05/ \sqrt{10}}=2.34

The calculation of the p-value will be a little different. If we only find the area under the normal curve above z = 2.34, then we have found the probability of obtaining a sample mean of 355.037 or higher—what about the probability of obtaining a low value?

In the case that the alternate hypothesis uses ≠, the p-value is found by doubling the tail area—in this case, we double the area above z = 2.34.

The area above z = 2.34 is 0.0096; thus, the p-value for this test is 0.0192.

If the machine is delivering 355 mL, then the probability of obtaining a sample mean this far (0.037 mL) or farther from 355 mL is 0.0096, or 0.96%. This is pretty rare; I'll reject the null hypothesis.

It appears that the machine is not working correctly.

N.B.: since the alternate hypothesis is ≠, we cannot conclude that the machine is delivering more than 355 mL—we can only say that the amount is different from 355 mL.

z Test for Two Means[edit]

Indications[edit]

The Null Hypothesis should be an assumption about the difference in the population means for two populations (note that the same quantitative variable must have been measured in each population). The data should consist of two samples of quantitative data (one from each population). The samples must be obtained independently from each other.

Requirements[edit]

The samples must be drawn from populations which have known Standard Deviations (or Variances). Also, the measured variable in each population (generically denoted x1 and x2) should have a Normal Distribution.

Note that if the distributions of the variables in the populations are non-normal (or unknown), the two-sample z-test can still be used for approximate results, provided the combined sample size (sum of sample sizes) is sufficiently large. Historically, a combined sample size of at least 30 has been considered sufficiently large; reality is (of course) much more complicated, but this rule of thumb is still in use in many textbooks.

Procedure[edit]

  • The Null Hypothesis:
H0 : μ1 - μ2 = δ

in which δ is the supposed difference in the expected values under the null hypothesis.

  • The Alternate Hypothesis:
H0 : μ1 - μ2 < δ
H0 : μ1 - μ2 > δ
H0 : μ1 - μ2 ≠ δ

For more information about the Null and Alternate Hypotheses, see the page on the z test for a single mean.

  • The Test Statistic:
z=\frac{(\bar{x}_1 - \bar{x}_2) - \delta}{\sqrt{\frac{\sigma _1^2}{n_1}+\frac{\sigma _2^2}{n_2}}}

Usually, the null hypothesis is that the population means are equal; in this case, the formula reduces to

z= \frac{\bar{x}_1 - \bar{x}_2}{\sqrt{\frac{\sigma _1^2}{n_1}+\frac{\sigma _2^2}{n_2}}}

In the past, the calculations were simpler if the Variances (and thus the Standard Deviations) of the two populations could be assumed equal. This process is called Pooling, and many textbooks still use it, though it is falling out of practice (since computers and calculators have all but removed any computational problems).

\frac{\bar{x}_1 - \bar{x}_2}
{\sigma \sqrt{\frac{1}{n_1} + \frac{1}{n_2}}}
  • The Significance (p-value)

Calculate the probability of observing a value of z (from a Standard Normal Distribution) using the Alternate Hypothesis to indicate the direction in which the area under the Probability Density Function is to be calculated. This is the Attained Significance, or p-value.

Note that some (older) methods first chose a Level Of Significance, which was then translated into a value of z. This made more sense (and was easier!) in the days before computers and graphics calculators.

  • Decision

The Attained Significance represents the probability of obtaining a test statistic as extreme, or more extreme, than ours—if the null hypothesis is true.

If the Attained Significance (p-value) is sufficiently low, then this indicates that our test statistic is unusual (rare)—we usually take this as evidence that the null hypothesis is in error. In this case, we reject the null hypothesis.

If the p-value is large, then this indicates that the test statistic is usual (common)—we take this as a lack of evidence against the null hypothesis. In this case, we fail to reject the null hypothesis.

It is common to use 5% as the dividing line between the common and the unusual; again, reality is more complicated.

Worked Examples[edit]

Do Professors Make More Money at Larger Universities?[edit]

Universities and colleges in the United States of America are categorized by the highest degree offered. Type IIA institutions offer a Master's Degree, and type IIB institutions offer a Baccalaureate degree. A professor, looking for a new position, wonders if the salary difference between type IIA and IIB institutions is really significant.

He finds that a random sample of 200 IIA institutions has a mean salary (for full professors) of $54,218.00, with standard deviation $8,450. A random sample of 200 IIB institutions has a mean salary (for full professors) of $46,550.00, with standard deviation $9,500 (assume that the sample standard deviations are in fact the population standard deviations).

Do these data indicate a significantly higher salary at IIA institutions?


The null hypothesis is that there is no difference; thus

H0 : μA = μB

(where μA is the true mean full professor salary at IIA institutions, and μB is the mean at IIB institutions)

He is looking for evidence that IIA institutions have a higher mean salary; thus the alternate hypothesis is

H1 : μA > μB

Since the hypotheses concern means from independent samples (we'll assume that these are independent samples), a two sample test is indicated. The samples are large, and the standard deviations are known (assumed?), so a two sample z-test is appropriate.

z=\frac{\mu _A -\mu _B}{\sqrt{\frac{\sigma _A ^2}{n _A}+\frac{\sigma _B ^2}{n _B}}}=
\frac{54218-46550}{\sqrt{\frac{8450 ^2}{200}+\frac{9500 ^2}{200}}}=
8.5292

Now we find the area to the right of z = 8.5292 in the Standard Normal Distribution. This can be done with a table of values or software—I get 0.

If the null hypothesis is true, and there is no difference in the salaries between the two types of institutions, then the probability of obtaining samples where the mean for IIA institutions is at least $7,668 higher than the mean for IIB institutions is essentially zero. This occurs far too rarely to attribute to chance variation; it seems quite unusual. I reject the null hypothesis (at any reasonable level of significance!).

It appears that IIA schools have a significantly higher salary than IIB schools.

Example 2[edit]

t Test for a single mean[edit]

The t- test is the most powerful parametric test for calculating the significance of a small sample mean.

A one sample t-test has the following null hypothesis:

H_0: \quad \mu=c

where the Greek letter \mu (mu) represents the population mean and c represents its assumed (hypothesized) value. In statistics it is usual to employ Greek letters for population parameters and Roman letters for sample statistics. The t-test is the small sample analog of the z test which is suitable for large samples. A small sample is generally regarded as one of size n<30.

A t-test is necessary for small samples because their distributions are not normal. If the sample is large (n>=30) then statistical theory says that the sample mean is normally distributed and a z test for a single mean can be used. This is a result of a famous statistical theorem, the Central limit theorem.

A t-test, however, can still be applied to larger samples and as the sample size n grows larger and larger, the results of a t-test and z-test become closer and closer. In the limit, with infinite degrees of freedom, the results of t and z tests become identical.

In order to perform a t-test, one first has to calculate the "degrees of freedom." This quantity takes into account the sample size and the number of parameters that are being estimated. Here, the population parameter, mu is being estimated by the sample statistic x-bar, the mean of the sample data. For a t-test the degrees of freedom of the single mean is n-1. This is because only one population parameter (the population mean)is being estimated by a sample statistic (the sample mean).

degrees of freedom (df)=n-1

For example, for a sample size n=15, the df=14.

Example[edit]

A college professor wants to compare her students' scores with the national average. She chooses an SRS of 20 students, who score an average of 50.2 on a standardized test. Their scores have a standard deviation of 2.5. The national average on the test is a 60. She wants to know if her students scored significantly lower than the national average.

Significance tests follow a procedure in several steps.

Step 1[edit]

First, state the problem in terms of a distribution and identify the parameters of interest. Mention the sample. We will assume that the scores (X) of the students in the professor's class are approximately normally distributed with unknown parameters μ and σ

Step 2[edit]

State the hypotheses in symbols and words.

H_O: \quad \mu=60

The null hypothesis is that her students scored on par with the national average.

H_A: \quad \mu<60

The alternative hypothesis is that her students scored lower than the national average.

Step 3[edit]

Secondly, identify the test to be used. Since we have an SRS of small size and do not know the standard deviation of the population, we will use a one-sample t-test.

The formula for the t-statistic T for a one-sample test is as follows:

T = \frac{\overline{X} - 60}{S/\sqrt{20}}

where \overline{X} is the sample mean and S is the sample standard deviation.

A quite common mistake is to say that the formula for the t-test statistic is:

T = \frac{\overline{x} - \mu}{s/\sqrt{n}}

This is not a statistic, because μ is unknown, which is the crucial point in such a problem. Most people even don't notice it. Another problem with this formula is the use of x and s. They are to be considered the sample statistics and not their values.

The right general formula is:

T = \frac{\overline{X} - c}{S/\sqrt{n}}

in which c is the hypothetical value for μ specified by the null hypothesis.

(The standard deviation of the sample divided by the square root of the sample size is known as the "standard error" of the sample.)

Step 4[edit]

State the distribution of the test statistic under the null hypothesis. Under H0 the statistic T will follow a Student's distribution with 19 degrees of freedom: T \sim \tau\cdot(20-1) .

Step 5[edit]

Compute the observed value t of the test statistic T, by entering the values, as follows:

t = \frac{\overline{x} - 60}{s/\sqrt{20}} = \frac{50.2 - 60.0}{2.5/\sqrt{20}} = \frac{-9.8}{2.5/4.47} = \frac{-9.8}{0.559} = -17.5

Step 6[edit]

Determine the so-called p-value of the value t of the test statistic T. We will reject the null hypothesis for too small values of T, so we compute the left p-value:

p-value  = P(T \leq t ;H_0) = P(T(19) \leq -17.5) \approx 0

The Student's distribution gives T(19)=1.729 at probabilities 0.95 and degrees of freedom 19. The p-value is approximated at 1.777e-13.

Step 7[edit]

Lastly, interpret the results in the context of the problem. The p-value indicates that the results almost certainly did not happen by chance and we have sufficient evidence to reject the null hypothesis. The professor's students did score significantly lower than the national average.

See also[edit]

t Test for Two Means[edit]

In both the one- and two-tailed versions of the small two-sample t-test, we assume that the means of the two populations are equal. To use a t-test for small (independent) samples, the following conditions must be met:

  1. The samples must be selected randomly.
  2. The samples must be independent.
  3. Each population must have a normal distribution.

A small two sample t-test is used to test the difference between two population means μ1 and μ2 when the sample size for at least one population is less than 30.The standardized test statistic is:

One-Way ANOVA F Test[edit]

The one-way ANOVA F-test is used to identify if there are differences between subject effects. For instance, to investigate the effect of a certain new drug on the number of white blood cells, in an experiment the drug is given to three different groups, one of healthy people, one with people with a light form of the considered disease and one with a severe form of the disease. Generally the analysis of variance identifies whether there is a significant difference in effect of the drug on the number of white blood cells between the groups. Significant refers to the fact that there will always be difference between the groups and also within the groups, but the purpose is to investigate whether the difference between the groups are large compared to the differences within the groups. To set up such an experiment three assumptions must be validated before calculating an F statistic: independent samples, homogeneity of variance, and normality. The first assumption suggests that there is no relation between the measurements for different subjects. Homogeneity of variance refers to equal variances among the different groups in the experiment (e.g., drug vs. placebo). Furthermore, the assumption of normality suggests that the distribution of each of these groups should be approximately normally distributed.

Model[edit]

The situation is modelled in the following way. The measurement of the j-th test person in group i is indicated by:khalil kakayi

X_{ij}=\mu+\alpha_i+U_{ij}\,.

This reads: the outcome of the measurement for j in group i is due to a general effect indicated by \mu\,, an effect due to the group, \alpha_i\, and an individual contribution U_{ij}\,.

The individual, or random, contributions U_{ij}\,, often referred to as disturbances, are considered to be independently, normally distributed, all with expected value 0 and standard deviation \sigma.

To make the model unambiguous the group effects are restrained by the condition:

\sum_i\alpha_i=0\,.

Now. a notational note: it is common practice to indicate averages over one or more indices by writing a dot in the place of the index or indices. So for instance

X_{i.} = \frac{1}{N}\sum^N_{j=1} X_{ij}

The analysis of variance now divides the total "variance" in the form of the total "sum of squares" in two parts, one due to the variation within the groups and one due to the variation between the groups:

SST=\sum_{ij}(X_{ij}-X{..})^2=\sum_{ij}(X_{ij}-X_{i.}+X_{i.}-X{..})^2=
\sum_{ij}(X_{ij}-X_{i.})^2+\sum_{ij}(X_{i.}-X{..})^2\,.

We see the term sum of squares of error:

SSE=\sum_{ij}(X_{ij}-X_{i.})^2\,

of the total squared differences of the individual measurements from their group averages, as an indication of the variation within the groups, and the term sum of square of the factor

SSA=\sum_{ij}(X_{i.}-X{..})^2\,

of the total squared differences of the group means from the overall mean, as an indication of the variation between the groups.

Under the null hypothesis of no effect:

H_0: \forall_i\ \alpha_i=0

we find:

SSE/\sigma^2\, is chi-square distributed with a(m-1) degrees of freedom, and
SSA/\sigma^2\, is chi-square distributed with a-1 degrees of freedom,

where a is the number of groups and m is the number of persons in each group.

Hence the quotient of the so-called mean sum of squares:

MSA=\frac{SSA}{a-1}

and

MSE=\frac{SSE}{a(m-1)}

may be used as a test statistic

F=\frac{MSA}{MSE}

which under the null hypothesis is F-distributed with a-1 degrees of freedom in the nominator and a(m-1) in the denominator, because the unknown parameter \sigma does not play a role since it is cancelled out in the quotient.

Testing whether Proportion A Is Greater than Proportion B in Microsoft Excel[edit]

A running example from the 2004 American Presidential Race follows. It should be clear that the choice of poll and who is leading is irrelevant to the presentation of the concepts. According to an October 2nd Poll by Newsweek (link), 47% of 1,013 registered voters would vote for John Kerry/John Edwards if the election were held today. 45% would vote for George Bush/Dick Cheney, and 2% would vote for Ralph Nader/Peter Camejo.

  • Open a new Blank Workbook in the program Microsoft Excel.
  • Enter Kerry's reported percentage p in cell A1 (0.47).
  • Enter Bush's reported percentage q in cell B1 (0.45).
  • Enter the number of respondents N in cell C1 (1013). This can be found in most responsible reports on polls.
  • In cell A2, copy and paste the next line of text in its entirety and press Enter. This is the Microsoft Excel expression of the standard error of the difference as shown above.
=sqrt(A1*(1-A1)/C1+B1*(1-B1)/C1+2*A1*B1/C1)
  • In cell A3, copy and paste the next line of text in its entirety and press Enter. This is the Microsoft Excel expression of the probability that Kerry is leading based on the normal distribution given the logic here.
=normdist((A1-B1),0,A2,1)
  • Don't forget that the percentages will be in decimal form. The percentage will be 0.5, or 50% if A1 and B1 are the same, of course.

The above text might be enough to do the necessary calculation, it doesn't contribute to the understanding of the statistical test involved. Much too often people think statistics is a matter of calculation with complex formulas.

So here is the problem: Let p be the population fraction of the registered voters who vote for Kerry and q likewise for Bush. In a poll n = 1013 respondents are asked to state their choice. A number of K respondents says to choose Kerry, a number B says to vote for Bush. K and B are random variables. The observed values for K and B are resp. k and b (numbers). So k/n is an estimate of p and b/n an estimate of q. The random variables K and B follow a trinomial distribution with parameters n, p, q and 1-p-q. Will Kerry be ahead of Bush? That is to say: wiil p > q? To investigate this we perform a statistical test, with null hypothesis:

\, H_0: p = q

against the alternative

\, H_1: p > q.

What is an appropriate test statistic T? We take:

\, T=K-B.

(In the above calculation T=\frac Kn - \frac Bn = \frac{K-B}n is taken, which leads to the same calculation.)

We have to state the distribution of T under the null hypothesis. We may assume T is approximately normally distributed.

It is quite obvious that its expectation under H0 is:

\, E_0T = 0.

Its variance under H0 is not as obvious.

\, var_0(T) = var(K-B) = var(K) + var(B) - 2cov(K,B) = np(1-p) + nq(1-q) + 2npq .

We approximate the variance by using the sample fractions instead of the population fractions:

var_0(T) \approx 1013\times 0.47(1-0,46) + 1013\times 0.45(1-0.45) + 2\times 1013\times 0,47\times0.45 \approx 931
.

The standard deviation s will approximately be:

\, s = \sqrt{var_0(T)} \approx \sqrt{931} = 30.5 .

In the sample we have found a value t = k - b = (0.47-0.45)1013 = 20.26 for T. We will reject the null hypothesis in favour of the alternative for large values of T. So the question is: is 20.26 to be considered a large value for T? The criterion will be the so called p-value of this outcome:

\, p-value = P(T\ge t; H_0) = P(T\ge 20.26; H_0) = P(Z\ge \frac{20.26}{30.5}) = 1-\Phi(0.67) = 0.25.

This is a very large p-value, so there is no reason whatsoever to reject the null hypothesis.

Chi-Squared Tests[edit]

General idea[edit]

Assume you have observed absolute frequencies o_i and expected absolute frequencies e_i under the Null hypothesis of your test then it holds

V = \sum_i \frac{(o_i-e_i)^2}{e_i} \approx \chi^2_f .

i might denote a simple index running from 1,...,I or even a multiindex (i_1,...,i_p) running from (1,...,1) to (I_1,...,I_p).

The test statistics V is approximately \chi^2 distributed, if

  1. for all absolute expected frequencies e_i holds e_i \geq 1 and
  2. for at least 80% of the absolute expected frequencies e_i holds e_i \geq 5.

Note: In different books you might find different approximation conditions, please feel free to add further ones.

The degrees of freedom can be computed by the numbers of absolute observed frequencies which can be chosen freely. We know that the sum of absolute expected frequencies is

 \sum_i o_i = n

which means that the maximum number of degrees of freedom is I-1. We might have to subtract from the number of degrees of freedom the number of parameters we need to estimate from the sample, since this implies further relationships between the observed frequencies.

Derivation of the distribution of the test statistic[edit]

Following Boero, Smith and Wallis (2002) we need knowledge about multivariate statistics to understand the derivation.

The random variable O describing the absolute observed frequencies (o_1, ..., o_k) in a sample has a multinomial distribution O \sim M(n;p_1,...,p_k) with n the number of observations in the sample, p_i the unknown true probabilities. With certain approximation conditions (central limit theorem) it holds that

O \sim M(n; p_1,...,p_k) \approx N_k(\mu;\Sigma)

with N_k the multivariate k dimensional normal distribution, \mu = (np_1,...,np_k) and

\Sigma = (\sigma_{ij})_{i,j=1,...,k} = \begin{cases} -np_ip_j, & \mbox{if } i\neq j \\  np_i(1-p_i) & \mbox{otherwise} \end{cases}.

The covariance matrix \Sigma has only rank k-1, since p_1+...+p_k = 1.

If we considered the generalized inverse \Sigma^- then it holds that

(O-\mu)^T \Sigma^- (O-\mu) = \sum_i \frac{(o_i-e_i)^2}{e_i} \sim \chi^2_{k-1}

distributed (for a proof see Pringle and Rayner, 1971).

Since the multinomial distribution is approximately multivariate normal distributed, the term is

\sum_i \frac{(o_i-e_i)^2}{e_i} \approx \chi^2_{k-1}

distributed. If further relations between the observed probabilities are there then the rank of \Sigma will decrease further.

A common situation is that parameters on which the expected probabilities depend needs to be estimated from the observed data. As said above, usually is stated that the degrees of freedom for the chi square distribution is k-1-r with r the number of estimated parameters. In case of parameter estimation with the maximum-likelihood method this is only true if the estimator is efficient (Chernoff and Lehmann, 1954). In general it holds that degrees of freedom are somewhere between k-1-r and k-1.

Examples[edit]

The most famous examples will be handled in detail at further sections: \chi^2 test for independence, \chi^2 test for homogeneity and \chi^2 test for distributions.

The \chi^2 test can be used to generate "quick and dirty" test, e.g.

H_0: The random variable X is symmetrically distributed versus

H_1: the random variable X is not symmetrically distributed.

We know that in case of a symmetrical distribution the arithmetic mean \bar{x} and median should be nearly the same. So a simple way to test this hypothesis would be to count how many observations are less than the mean (n_-)and how many observations are larger than the arithmetic mean (n_+). If mean and median are the same than 50% of the observation should smaller than the mean and 50% should be larger than the mean. It holds

V = \frac{(n_- - n/2)^2}{n/2} + \frac{(n_+ - n/2)^2}{n/2} \approx \chi^2_1.

References[edit]

Numerical Methods[edit]

Often the solution of statistical problems and/or methods involve the use of tools from numerical mathematics. An example might be Maximum-Likelihood estimation of \widehat{\Theta}which involves the maximization of the Likelihood function L:

\widehat{\Theta} = \max_\theta\,\, L(\theta | x_1, ..., x_n).

The maximization here requires the use of optimization routines. Other numerical methods and their application in statistics are described in this section.

Contents of this section:

This section is dedicated to the Gram-Schmidt Orthogonalization which occurs frequently in the solution of statistical problems. Additionally some results of algebra theory which are necessary to understand the Gram-Schmidt Orthogonalization are provided. The Gram-Schmidt Orthogonalization is an algorithm which generates from a set of linear dependent vectors a new set of linear independent vectors which span the same space. Computation based on linear independent vectors is simpler than computation based on linear dependent vectors.

Numerical Optimization occurs in all kind of problem - a prominent example being the Maximum-Likelihood estimation as described above. Hence this section describes one important class of optimization algorithms, namely the so-called Gradient Methods. After describing the theory and developing an intuition about the general procedure, three specific algorithms (the Method of Steepest Descent, the Newtonian Method, the class of Variable Metric Methods) are described in more detail. Especially we provide an (graphical) evaluation of the performance of these three algorithms for specific criterion functions (the Himmelblau function and the Rosenbrock function). Furthermore we come back to Maximum-Likelihood estimation and give a concrete example how to tackle this problem with the methods developed in this section.

In OLS, one has the primary goal of determining the conditional mean of random variable Y, given some explanatory variable x_i , E[Y|x_i]. Quantile Regression goes beyond this and enables us to pose such a question at any quantile of the conditional distribution function. It thereby focuses on the interrelationship between a dependent variable and its explanatory variables for a given quantile.

Statistical calculations require an extra accuracy and are open to some errors such as truncation or cancellation error etc. These errors occur due to binary representation and finite precision and may cause inaccurate results. In this work we are going to discuss the accuracy of the statistical software, different tests and methods available for measuring the accuracy and the comparison of different packages.

The purpose of this paper is to evaluate the accuracy of MS Excel in terms of statistical procedures and to conclude whether the MS Excel should be used for (statistical) scientific purposes or not. The evaluation is made for MS Excel versions 97, 2000, XP and 2003.

Basic Linear Algebra and Gram-Schmidt Orthogonalization[edit]

Introduction[edit]

Basically, all the sections found here can be also found in a linear algebra book. However, the Gram-Schmidt Orthogonalization is used in statistical algorithm and in the solution of statistical problems. Therefore, we briefly jump into the linear algebra theory which is necessary to understand Gram-Schmidt Orthogonalization.

The following subsections also contain examples. It is very important for further understanding that the concepts presented here are not only valid for typical vectors as tuple of real numbers, but also functions that can be considered vectors.

Fields[edit]

Definition[edit]

A set R with two operations + and * on its elements is called a field (or short (R,+,*)), if the following conditions hold:

  1. For all \alpha, \beta \in R holds \alpha+\beta \in R
  2. For all \alpha, \beta \in R holds \alpha+\beta = \beta+\alpha (commutativity)
  3. For all \alpha, \beta,\gamma \in R holds \alpha+(\beta+\gamma) = (\alpha+\beta)+\gamma (associativity)
  4. It exist a unique element 0, called zero, such that for all \alpha \in R holds \alpha+0 = \alpha
  5. For all \alpha \in R a unique element -\alpha, such that holds \alpha+ (-\alpha) = 0
  6. For all \alpha, \beta \in R holds \alpha*\beta \in R
  7. For all \alpha, \beta \in R holds \alpha*\beta = \beta*\alpha (commutativity)
  8. For all \alpha, \beta,\gamma \in R holds \alpha*(\beta*\gamma) = (\alpha*\beta)*\gamma (associativity)
  9. It exist a unique element 1, called one, such that for all \alpha \in R holds \alpha*1 = \alpha
  10. For all non-zero \alpha \in R a unique element \alpha^{-1}, such that holds \alpha * \alpha^{-1} = 1
  11. For all \alpha, \beta,\gamma \in R holds \alpha*(\beta+\gamma) = \alpha*\beta+\alpha*\gamma (distributivity)

The elements of R are also called scalars.

Examples[edit]

It can easily be proven that real numbers with the well known addition and multiplication (IR, +, *) are a field. The same holds for complex numbers with the addition and multiplication. Actually, there are not many more sets with two operations which fulfill all of these conditions.

For statistics, only the real and complex numbers with the addition and multiplication are important.

Vector spaces[edit]

Definition[edit]

A set V with two operations + and * on its elements is called a vector space over R, if the following conditions hold:

  1. For all x, y\in V holds x+y \in V
  2. For all x, y \in V holds x+y = y+x (commutativity)
  3. For all x, y, z \in V holds x+(y+z) = (x+y)+z (associativity)
  4. It exist a unique element \mathbb{O}, called origin, such that for all x \in V holds x+\mathbb{O} = x
  5. For all x \in V exists a unique element -v, such that holds x+ (-x) = \mathbb{O}
  6. For all \alpha\in R and x\in V holds \alpha*x \in V
  7. For all \alpha, \beta \in R and x\in V holds \alpha*(\beta*x) = (\alpha*\beta)*x (associativity)
  8. For all x\in V and 1 \in R holds 1*x = x
  9. For all \alpha\in R and for all x, y\in Vholds \alpha*(x+y) = \alpha*x+\alpha*y (distributivity wrt. vector addition)
  10. For all \alpha, \beta \in R and for all x\in Vholds (\alpha+\beta)*x = \alpha*x+\beta*x (distributivity wrt. scalar addition)

Note that we used the same symbols + and * for different operations in R and V. The elements of V are also called vectors.

Examples:

  1. The set IR^p with the real-valued vectors (x_1,...,x_p) with elementwise addition x+y=(x_1+y_1,...,x_p+y_p) and the elementwise multiplication \alpha*x = (\alpha x_1,...,\alpha x_p) is a vector space over IR.
  2. The set of polynomials of degree p, P(x) = b_0 + b_1 x + b_2 x^2 + ... + b_p x^p, with usual addition and multiplication is a vector space over IR.

Linear combinations[edit]

A vector x can be written as a linear combination of vectors x_1,...x_n, if

x = \sum_{i=1}^n \alpha_i x_i

with \alpha_i \in R.

Examples:

  • (1,2,3) is a linear combination of (1,0,0),\,(0,1,0), \,(0,0,1) since (1,2,3)=1*(1,0,0)+2*(0,1,0)+3*(0,0,1)
  • 1+2*x+3*x^2 is a linear combination of 1+x+x^2,\, x+x^2,\, x^2 since 1+2*x+3*x^2=1*(1+x+x^2)+1*(x+x^2)+1*(x^2)

Basis of a vector space[edit]

A set of vectors x_1, ..., x_n is called a basis of the vector space V, if

1. for each vector x \in V exist scalars \alpha_1,...,\alpha_n \in R such that x = \sum_i \alpha_i x_i 2. there is no subset of \{ x_1, ..., x_n \} such that 1. is fulfilled.

Note, that a vector space can have several bases.

Examples:

  • Each vector (\alpha_1, \alpha_2, \alpha_3) \in IR^3 can be written as \alpha_1 * (1,0,0) + \alpha_2 *(0,1,0) + \alpha_3 * (0,0,1). Therefore is \{(1,0,0), (0,1,0), (0,0,1) \} a basis of IR^3.
  • Each polynomial of degree p can be written as linear combination of \{ 1, x, x^2, ..., x^p\} and therefore forms a basis for this vector space.

Actually, for both examples we would have to prove condition 2., but it is clear that it holds.

Dimension of a vector space[edit]

A dimension of a vector space is the number of vectors which are necessary for a basis. A vector space has infinitely many number of basis, but the dimension is uniquely determined. Note that the vector space may have a dimension of infinity, e.g. consider the space of continuous functions.

Examples:

  • The dimension of IR^3 is three, the dimension of IR^p is p .
  • The dimension of the polynomials of degree p is p+1.

Scalar products[edit]

A mapping <.,.>: V\times V \rightarrow R is called a scalar product if the following holds for all x,x_1,x_2,y,y_1,y_2 \in V and \alpha_1, \alpha_2 \in R :

  1. <\alpha_1 x_1 + \alpha_2 x_2, y> = \alpha_1 <x_1,y> + \alpha_2 <x_2, y>
  2. <x, \alpha_1 y_1 + \alpha_2 y_2> = \alpha_1 <x,y_1> + \alpha_2 <x, y_2>
  3. <x,y> = \overline{<y,x>} with \overline{\alpha + \imath \beta} = \alpha - \imath \beta
  4. <x,x> \geq 0 with  <x,x>=0 \Leftrightarrow x = \mathbb{O}

Examples:

  • The typical scalar product in IR^p is <x,y> = \sum_i x_i y_i.
  • <f,g> = \int_a^b f(x)*g(x) dx is a scalar product on the vector space of polynomials of degree p.

Norm[edit]

A norm of a vector is a mapping \|.\|: V \rightarrow R, if holds

  1. \| x \| \geq 0 for all x \in V and \| x \| =0 \Leftrightarrow x=\mathbb{O} (positive definiteness)
  2. \| \alpha v \|= \mid \alpha \mid \| x \| for all x\in V and all \alpha\in R
  3. \| x+y \| \leq \| x \| + \| y \| for all x,y\in V (triangle inequality)

Examples:

  • The L_q norm of a vector in IR^p is defined as \|x\|_q = \sqrt[q]{\sum_{i=1}^p x_i^q}.
  • Each scalar product generates a norm by \|x\| = \sqrt{<x,x>}, therefore \|f\| = \sqrt{\int_a^b f^2(x) dx} is a norm for the polynomials of degree p.

Orthogonality[edit]

Two vectors x and y are orthogonal to each other if <x,y>=0. In IR^p it holds that the cosine of the angle between two vectors can expressed as

\cos(\angle(x,y)) = \frac{<x,y>}{\|x\|\|y\|}.

If the angle between x and y is ninety degree (orthogonal) then the cosine is zero and it follows that <x,y>=0.

A set of vectors x_1, ..., x_p is called orthonormal, if

<x_i,x_j> = \begin{cases} 0 & \mbox{ if } i\neq j \\ 1 & \mbox{ if } i=j \end{cases}.

If we consider a basis e_1,..., e_p of a vector space then we would like to have a orthonormal basis. Why ?

Since we have a basis, each vector x and y can be expressed by x=\alpha_1 e_1 + ... +\alpha_p e_p and y=\beta_1 e_1 + ... +\beta_p e_p. Therefore the scalar product of x and y reduces to

<x,y>\ = <\alpha_1 e_1 + ... +\alpha_p e_p, \beta_1 e_1 + ... +\beta_p e_p>\
 = \sum_{i=1}^p \sum_{j=1}^p \alpha_i \beta_j <e_i, e_j>
 =  \sum_{i=1}^p  \alpha_i \beta_i <e_i, e_i>
 = \alpha_1 \beta_1 + ... + \alpha_p \beta_p.\

Consequently, the computation of a scalar product is reduced to simple multiplication and addition if the coefficients are known. Remember that for our polynomials we would have to solve an integral!

Gram-Schmidt orthogonalization[edit]

Algorithm[edit]

The aim of the Gram-Schmidt orthogonalization is to find for a set of vectors x_1, ..., x_p an equivalent set of orthonormal vectors o_1,...,o_p such that any vector which can be expressed as linear combination of x_1, ..., x_p can also be expressed as linear combination of o_1,...,o_p:

1. Set b_1 = x_1 and o_1 = b_1 / \|b_1\|

2. For each i>1 set b_i = x_i - \sum_{j=1}^{i-1} \frac{<x_i, b_j>}{<b_j,b_j>} b_j and o_i = b_i / \|b_i\|, in each step the vector x_i is projected on b_j and the result is subtracted from x_i.

Vector2.jpg

Example[edit]

Consider the polynomials of degree two in the interval[-1,1] with the scalar product <f,g> = \int_{-1}^1 f(x) g(x) dx and the norm \|f\| = \sqrt{<f,f>}. We know that f_1(x)=1, f_2(x)=x and f_3(x)=x^2 are a basis for this vector space. Let us now construct an orthonormal basis:

Step 1a: b_1(x) = f_1(x) = 1

Step 1b: o_1(x) = \frac{b_1(x)}{\|b_1(x)\|} = \frac{1}{\sqrt{<b_1(x), b_1(x)>}} = \frac{1}{\sqrt{\int_{-1}^1 1 dx}} = \frac{1}{\sqrt{2}}

Step 2a: b_2(x) = f_2(x) - \frac{<f_2(x),b_1(x)>}{<b_1(x),b_1(x)>} b_1(x) = x - \frac{\int_{-1}^1 x\ 1 dx}{2} 1 = x - \frac{0}{2} 1 = x

Step 2b: o_2(x) = \frac{b_2(x)}{\|b_2(x)\|} = \frac{x}{\sqrt{<b_2(x), b_2(x)>}} = \frac{x}{\sqrt{\int_{-1}^1 x^2 dx}} = \frac{x}{\sqrt{2/3}} = x\sqrt{3/2}

Step 3a: b_3(x) = f_3(x) - \frac{<f_3(x),b_1(x)>}{<b_1(x),b_1(x)>} b_1(x) - \frac{<f_3(x),b_2(x)>}{<b_2(x),b_2(x)>} b_2(x) = x^2 - \frac{\int_{-1}^1 x^2 1\  dx}{2} 1 - \frac{\int_{-1}^1 x^2 x\ dx}{2/3} x = x^2 - \frac{2/3}{2} 1 - \frac{0}{2/3} x = x^2 - 1/3

Step 3b: o_3(x) = \frac{b_3(x)}{\|b_3(x)\|} = \frac{x^2-1/3}{\sqrt{<b_3(x), b_3(x)>}} = \frac{x^2-1/3}{\sqrt{\int_{-1}^1 (x^2-1/3)^2 dx}} = \frac{x^2-1/3}{\sqrt{\int_{-1}^1 x^4 - 2/3 x^2 + 1/9\ dx}} = \frac{x^2-1/3}{\sqrt{8/45}} = \sqrt{\frac{5}{8}} (3x^2-1)

It can be proven that 1/\sqrt{2}, x\sqrt{3/2} and \sqrt{\frac{5}{8}} (3x^2-1) form a orthonormal basis with the above scalarproduct and norm.

Numerical instability[edit]

Consider the vectors x_1 = (1,\epsilon, 0, 0), x_2 = (1,0,\epsilon,0) and x_3 = (1,0,0,\epsilon). Assume that \epsilon is so small that computing 1+\epsilon = 1 holds on a computer (see http://en.wikipedia.org/wiki/Machine_epsilon). Let compute a orthonormal basis for this vectors in IR^4 with the standard scalar product <x,y>=x_1y_1+x_2y_2+x_3y_3+x_4y_4 and the norm \|x\| = \sqrt{x_1^2+x_2^2+x_3^2+x_4^2}.

Step 1a. b_1 = x_1 = (1,\epsilon,0,0)

Step 1b. o_1 = \frac{b_1}{\|b_1\|} = \frac{b_1}{\sqrt{1+\epsilon^2}} = b_1 with 1+\epsilon^2=1

Step 2a. b_2 = x_2 - \frac{<x_2,b_1>}{<b_1,b_1>} b_1 = (1,0,\epsilon,0) - \frac{1}{1+\epsilon^2} (1,\epsilon,0,0) = (0,-\epsilon,\epsilon,0)

Step 2b. o_2 = \frac{b_2}{\|b_2\|} = \frac{b_2}{\sqrt{2\epsilon^2}} = (0,-\frac{1}{\sqrt{2}},\frac{1}{\sqrt{2}},0)

Step 3a. b_3 = x_3 -  \frac{<x_3,b_1>}{<b_1,b_1>} b_1 - \frac{<x_3,b_2>}{<b_2,b_2>} b_2 = (1,0,0,\epsilon) - \frac{1}{1+\epsilon^2} (1,\epsilon,0,0) - \frac{0}{2\epsilon^2} (0,-\epsilon,\epsilon,0) = (0, -\epsilon, 0,\epsilon)

Step 3b. o_3 = \frac{b_3}{\|b_3\|} = \frac{b_3}{\sqrt{2\epsilon^2}} = (0,-\frac{1}{\sqrt{2}},0,\frac{1}{\sqrt{2}})

It obvious that for the vectors

- o_1 = (1, \epsilon, 0, 0)\

- o_2 = (0,-\frac{1}{\sqrt{2}},\frac{1}{\sqrt{2}},0)

- o_3 = (0,-\frac{1}{\sqrt{2}},0,\frac{1}{\sqrt{2}})

the scalarproduct <o_2,o_3> = 1/2 \neq 0. All other pairs are also not zero, but they are multiplied with \epsilon such that we get a result near zero.

Modified Gram-Schmidt[edit]

To solve the problem a modified Gram-Schmidt algorithm is used:

  1. Set b_i = x_i for all i
  2. for each i from 1 to n compute
    1. o_i = \frac{b_i}{\|b_i\|}
    2. for each j from i+1 to n compute b_j = b_j - <b_j, o_i> o_i\

The difference is that we compute first our new b_i and subtract it from all other b_j. We apply the wrongly computed vector to all vectors instead of computing each b_i separately.

Example (recomputed)[edit]

Step 1. b_1 = (1,\epsilon,0,0), b_2 = (1,0,\epsilon,0), b_3 = (1,0,0,\epsilon)

Step 2a. o_1 = \frac{b_1}{\|b_1\|} = \frac{b_1}{\sqrt{1+\epsilon^2}} = b_1 = (1,\epsilon,0,0) with 1+\epsilon^2=1

Step 2b. b_2 = b_2 - <b_2, o_1> o_1 = (1,0,\epsilon,0) - (1,\epsilon,0,0) = (0, -\epsilon, \epsilon, 0)\

Step 2c. b_3 = b_3 - <b_3, o_1> o_1 = (1,0,0,\epsilon) - (1,\epsilon,0,0) = (0, -\epsilon, 0, \epsilon)\

Step 3a. o_2 = \frac{b_2}{\|b_2\|} = \frac{b_2}{\sqrt{2\epsilon^2}} =  (0,-\frac{1}{\sqrt{2}}, \frac{1}{\sqrt{2}}, 0)

Step 3b. b_3 = b_3 - <b_3, o_2> o_2 = (0, -\epsilon, 0, \epsilon) - \frac{\epsilon}{\sqrt{2}}  (0,-\frac{1}{\sqrt{2}}, \frac{1}{\sqrt{2}}, 0) = (0, -\epsilon/2, -\epsilon/2, \epsilon)

Step 4a. o_3 = \frac{b_3}{\|b_3\|} = \frac{b_3}{\sqrt{3/2\epsilon^2}} =  (0,-\frac{1}{\sqrt{6}}, -\frac{1}{\sqrt{6}}, \frac{2}{\sqrt{6}})

We can easily verify that <o_2,o_3> = 0.


Application[edit]

Exploratory Project Pursuit[edit]

In the analysis of high-dimensional data we usually analyze projections of the data. The approach results from the Theorem of Cramer-Wold that states that the multidimensional distribution is fixed if we know all one-dimensional projections. Another theorem states that most (one-dimensional) projections of multivariate data are looking normal, even if the multivariate distribution of the data is highly non-normal.

Therefore in Exploratory Projection Pursuit we jugde the interestingness of a projection by comparison with a (standard) normal distribution. If we assume that the one-dimensional data x are standard normal distributed then after the transformation z=2\Phi^{-1}(x)-1 with \Phi(x) the cumulative distribution function of the standard normal distribution then z is uniformly distributed in the interval [-1;1].

Thus the interesting can measured by \int_{-1}^1 (f(z)-1/2)^2 dx with f(z) a density estimated from the data. If the density f(z) is equal to 1/2 in the interval [-1;1] then the integral becomes zero and we have found that our projected data are normally distributed. An value larger than zero indicates a deviation from the normal distribution of the projected data and hopefully an interesting distribution.

Expansion with orthonormal polynomials[edit]

Let L_i(z) a set of orthonormal polynomials with the scalar product <f,g>=\int_{-1}^1 f(z)g(z) dz and the norm \|f\| = \sqrt{<f,f>}. What can we derive about a densities f(z) in the interval [-1;1] ?

If f(z)=\sum_{i=0}^I a_i L_i(z) for some maximal degree I then it holds

\int_{-1}^1 f(z) L_j(z) dz = \int_{-1}^1 \sum_{i=0}^I a_i L_i(z) L_j(z) dz = a_j \int_{-1}^1 L_j(z) L_j(z) dz = a_j

We can also write \int_{-1}^1 f(z) L_j(z) dz = E(L_j(z)) or empirically we get an estimator \hat{a}_j = \frac{1}{n} \sum_{k=1}^n L_j(z_k).

We describe the term 1/2 = \sum_{i=1}^I b_i L_i(z) and get for our integral

\int_{-1}^1 (f(z)-1/2)^2 dz = \int_{-1}^1 \left(\sum_{i=0}^I (a_i-b_i) L_i(z)\right)^2 dz  = \sum_{i,j=0}^I \int_{-1}^1 (a_i-b_i)(a_j-b_j) L_i(z) L_j(z) dz = \sum_{i=0}^I (a_i-b_i)^2.

So using a orthonormal function set allows us to reduce the integral to a summation of coefficient which can be estimated from the data by plugging \hat{a}_j in the formula above. The coefficients b_i can be precomputed in advance.

Normalized Legendre polynomials[edit]

The only problem left is to find the set of orthonormal polynomials L_i(z) upto degree I. We know that 1, x, x^2, ..., x^I form a basis for this space. We have to apply the Gram-Schmidt orthogonalization to find the orthonormal polynomials. This has been started in the first example.

The resulting polynomials are called normalized Legendre polynomials. Up to a sacling factor the normalized Legendre polynomials are identical to Legendre polynomials. The Legendre polynomials have a recursive expression of the form

L_i(z) = \frac{(2i-1) L_{i-1}(z) - (i-1) L_{i-2}(z)}{i}

So computing our integral reduces to computing L_0(z_k) and L_1(z_k) and using the recursive relationship to compute the \hat{a}_j's. Please note that the recursion can be numerically unstable!

References[edit]

Unconstrained Optimization[edit]

Introduction[edit]

In the following we will provide some notes on numerical optimization algorithms. As there are numerous methods out there, we will restrict ourselves to the so-called Gradient Methods. There are basically two arguments why we consider this class as a natural starting point when thinking about numerical optimization algorithms. On the one hand, these methods are really workhorses in the field, so their frequent use in practice justifies their coverage here. On the other hand, this approach is highly intuitive in the sense that it somewhat follow naturally from the well-known properties of optima. In particular we will concentrate on three examples of this class: the Newtonian Method, the Method of Steepest Descent and the class of Variable Metric Methods, nesting amongst others the Quasi Newtonian Method.

Before we start we will nevertheless stress that there does not seem to be a "one and only" algorithm but the performance of specific algorithms is always contingent on the specific problem to be solved. Therefore both experience and "trial-and-error" are very important in applied work. To clarify this point we will provide a couple of applications where the performance of different algorithms can be compared graphically. Furthermore a specific example on Maximum Likelihood Estimation can be found at the end. Especially for statisticians and econometricians the Maximum Likelihood Estimator is probably the most important example of having to rely on numerical optimization algorithms in practice.

Theoretical Motivation[edit]

Any numerical optimization algorithm has solve the problem of finding "observable" properties of the function such that the computer program knows that a solution is reached. As we are dealing with problems of optimization two well-known results seem to be sensible starting points for such properties.

If f is differentiable and x^\star is a (local) minimum, then

 (1a) \quad Df(x^\star) = 0

i.e. the Jacobian  D f(x) is equal to zero

and

If f is twice differentiable and  x^\star is a (local) minimum, then

 (1b) \quad x^{T}D^2 f(x^\star)x \geq 0

i.e. the Hessian  D^2 f(x) is pos. semidefinite.

In the following we will always denote the minimum by  x^\star . Although these two conditions seem to represent statements that help in finding the optimum  x^\star , there is the little catch that they give the implications of  x^\star being an optimum for the function  f . But for our purposes we would need the opposite implication, i.e. finally we want to arrive at a statement of the form: "If some condition  g(f(x^\star)) is true, then  x^\star is a minimum". But the two conditions above are clearly not sufficient in achieving this (consider for example the case of  f(x) = x^3 , with  Df(0) = D^2 f(0) = 0 but  x^{\star} \neq 0 ). Hence we have to look at an entire neighborhood of  x^\star as laid out in the following sufficient condition for detecting optima:


If  Df(x^\star) = 0 and  x^{T}D^2f(z)x \geq 0, \forall x \in \mathbb{R}^n and  z \in \mathcal{B}(x^\star, \delta), then: x^\star is a local minimum.

Proof: For  x \in \mathcal{B}(x^\star, \delta) let  z=x^\star + t(x-x^\star) \in \mathcal{B} . The Taylor approximation yields:  f(x) - f(x^\star) = 0 + \frac{1}{2}(x-x^\star)^{T}D^2 f(z)(x-x^\star) \geq 0 , where  \mathcal{B}(x^\star, \delta) denotes an open ball around  x^\star , i.e.  \mathcal{B}(x^\star, \delta) = \{x : ||x - x^\star|| \leq \delta \} for  \delta > 0 .


In contrast to the two conditions above, this condition is sufficient for detecting optima - consider the two trivial examples

 f(x) = x^3 with  Df(x^\star = 0) = 0 but  x^{T}D^2f(z)x = 6 z x^2 \not\geq 0 \quad (e.g. \,\,z = -\frac{\delta}{2})

and

f(x) = x^4 with  Df(x^\star = 0) = 0 and x^{T}D^2f(z)x = 12 z^2 x^2 \geq 0 \quad \forall z.

Keeping this little caveat in mind we can now turn to the numerical optimization procedures.

Numerical Solutions[edit]

All the following algorithms will rely on the following assumption:

(A1) The set  N(f,f(x^{(0)}) = \{x \in \mathbb{R}^n | f(x) \leq f(x^{(0)})\} is compact

where  x^{(0)} is some given starting value for the algorithm. The significance of this assumption has to be seen in the Weierstrass Theorem which states that every compact set contains its supremum and its infimum. So (A1) ensures that there is some solution in  N(f,f(x^{(0)}) . And at this global minimum  x^\star it of course holds true that  D(f(x^\star)) = 0 . So - keeping the discussion above in mind - the optimization problem basically boils down to the question of solving set of equations  D(f(x^\star)) = 0 .

The Direction of Descent[edit]

The problems with this approach are of course rather generically as  D(f(x^\star)) = 0 does hold true for maxima and saddle points as well. Hence, good algorithms should ensure that both maxima and saddle points are ruled out as potential solutions. Maxima can be ruled out very easily by requiring  f(x^{(k+1)}) < f(x^{(k)}) i.e. we restrict ourselves to a sequence  \{x^{(k)} \}_{k} such that the function value decreases in every step. The question is of course if this is always possible. Fortunately it is. The basic insight why this is the case is the following. When constructing the mapping  x^{(k+1)} = \varphi(x^{(k)}) (i.e. the rule how we get from x^{(k)} to x^{(k+1)}) we have two degrees of freedoms, namely

  • the direction  d^{(k)} and
  • the step length \sigma^{(k)}.

Hence we can choose in which direction we want to move to arrive at x^{(k+1)} and how far this movement has to be. So if we choose d^{(k)} and \sigma^{(k)} in the "right way" we can effectively ensure that the function value decreases. The formal representation of this reasoning is provided in the following


Lemma: If  d^{(k)} \in \mathbb{R}^n and  Df(x)^{T}d^{(k)} < 0 then: \exists \bar{\sigma} > 0 such that

 f(x + \sigma^{(k)} d^{(k)}) < f(x) \quad \forall \sigma \in
(0,\bar{\sigma})

Proof: As Df(x)^{T} d^{(k)} < 0 and Df(x)^{T} d^{(k)} = \lim_{\sigma \rightarrow 0} \frac{f(x + \sigma^{(k)} d^{(k)}) - f(x)}{\sigma^{(k)}}, it follows that f(x + \sigma^{(k)} d^{(k)}) < f(x) for \sigma^{(k)} small enough.

The General Procedure of Descending Methods[edit]

A direction vector d^{(k)} that satisfies this condition is is called a Direction of Descent. In practice this Lemma allows us to use the following procedure to numerically solve optimization problems.

1. Define the sequence  \{x^{(k)} \}_{k} recursively via  x^{(k+1)} = x^{(k)} + \sigma^{(k)} d^{(k)}

2. Choose the direction d^{(k)} from local information at the point x^{(k)}

3. Choose a step size \sigma^{(k)} that ensures convergence of the algorithm.

4. Stop the iteration if |f(x^{(k+1)}) - f(x^{(k)})| < \epsilon where \epsilon > 0 is some chosen tolerance value for the minimum

This procedure already hints that the choice of d^{(k)} and \sigma^{(k)} are not separable, but rather dependent. Especially note that even if the method is a descending method (i.e. both d^{(k)} and \sigma^{(k)} are chosen according to Lemma 1) the convergence to the minimum is not guaranteed. At a first glance this may seem a bit puzzling. If we found a sequence  \{x^{(k)} \}_{k} such that the function value decreases at every step, one might think that at some stage, i.e. in the limit of k tending to infinity we should reach the solution. Why this is not the case can be seen from the following example borrowed from W. Alt (2002, p. 76).

Example 1[edit]

  • Consider the following example which does not converge although it is clearly descending. Let the criterion function be given by

f(x) = x^2, let the starting value be x^{(0)} = 1, consider a (constant) direction vector d^{(k)}=-1 and choose a step width of \sigma^{(k)} = (\frac{1}{2})^{k+2}. Hence the recursive definition of the sequence \{x^{(k)} \}_{k} follows as

(2) \quad x^{(k+1)} = x^{(k)} + (\frac{1}{2})^{k+2} (-1) = x^{(k-1)} - (\frac{1}{2})^{k+1} - (\frac{1}{2})^{k+2} = x^{(0)} -
\sum_{j=0}^{k} (\frac{1}{2})^{j+2}.

Note that  x^{(k)} > 0 \,\, \forall \,\, k and hence  f(x^{(k+1)}) < f(x^{(k)}) \,\, \forall \,\,k, so that it is clearly a descending method. Nevertheless we find that

(3) \quad lim_{k \rightarrow \infty}x^{(k)} = lim_{k \rightarrow \infty} x^{(0)} - \sum_{j=0}^{k-1} (\frac{1}{2})^{j+2} = lim_{k \rightarrow \infty} 1 - \frac{1}{4}(\frac{1-(\frac{1}{2})^{k}}{\frac{1}{2}}) = lim_{k \rightarrow \infty} \frac{1}{2} + (\frac{1}{2})^{k+1} = \frac{1}{2} \neq 0 = x^\star.

The reason for this non-convergence has to be seen in the stepsize \sigma^{(k)} decreasing too fast. For large k the steps x^{(k+1)} - x^{(k)} get so small that convergence is precluded. Hence we have to link the stepsize to the direction of descend d^{(k)}.

Efficient Stepsizes[edit]

The obvious idea of such a linkage is to require that the actual descent is proportional to a first order approximation, i.e. to choose \sigma^{(k)} such that there is a constant c_1 > 0 such that

  (4) \quad f(x^{(k)} + \sigma^{(k)}d^{(k)}) - f(x^{(k)}) \leq c_1
\sigma^{(k)} D(f(x^{(k)})) d^{(k)} < 0.

Note that we still look only at descending directions, so that  Df(x^{(k)})^{T}d^{(k)} < 0 as required in Lemma 1 above. Hence, the compactness of  N(f,f(x^{(k)})) implies the convergence of the LHS and by (4)

 (5) \quad \lim_{k \rightarrow \infty} \sigma^{(k)} D(f(x^{(k)}))
d^{(k)} = 0.

Finally we want to choose a sequence  \{x^{(k)} \}_{k} such that  \lim_{k \rightarrow \infty}D(f(x^{(k)})) = 0 because that is exactly the necessary first order condition we want to solve. Under which conditions does (5) in fact imply  \lim_{k \rightarrow \infty}D(f(x^{(k)})) = 0 ? First of all the stepsize  \sigma^{(k)} must not go to zero too quickly. That is exactly the case we had in the example above. Hence it seems sensible to bound the stepsize from below by requiring that

 (6) \quad \sigma^{(k)} \geq -c_{2} \frac{Df(x^{(k)})^{T}d^{(k)}}{||
d^{(k)}||^{2}} > 0

for some constant c_2 > 0. Substituting (6) into (5) finally yields

 (7) \quad f(x^{(k)} + \sigma^{(k)}d^{(k)}) - f(x^{(k)}) \leq -c
(\frac{Df(x^{(k)})^{T}d^{(k)}}{|| d^{(k)}||})^{2}, \quad c = c_1
c_2

where again the compactness of  N(f,f(x^{(k)})) ensures the convergence of the LHS and hence

 (8) \quad lim_{k \rightarrow \infty} -c
(\frac{Df(x^{(k)})^{T}d^{(k)}}{|| d^{(k)}||})^{2} = lim_{k
\rightarrow \infty} \frac{Df(x^{(k)})^{T}d^{(k)}}{|| d^{(k)}||} =
0

Stepsizes that satisfy (4) and (6) are called efficient stepsizes and will be denoted by \sigma_{E}^{(k)}. The importance of condition (6) is illustrated in the following continuation of Example 1.

Example 1 (continued)[edit]

  • Note that it is exactly the failure of (6) that induced Example 1 not to converge. Substituting the stepsize of the example into (6) yields

(6.1) \quad \sigma^{(k)} = (\frac{1}{2})^{(k+2)} \geq -c_{2} \frac{2x^{(k)}(-1)}{1} = c_{2}\cdot2(\frac{1}{2}+(\frac{1}{2})^{k+1}) \Leftrightarrow \frac{1}{4(1+2^{(k)})} \geq c_{2} > 0

so there is no constant c_{2} > 0 satisfying this inequality for all k as required in (6). Hence the stepsize is not bounded from below and decreases too fast. To really acknowledge the importance of (6), let us change the example a bit and assume that \sigma^{(k)} = (\frac{1}{2})^{k+1}. Then we find that

(6.2) \quad lim_{k \rightarrow \infty} x^{(k+1)} = lim_{k \rightarrow
\infty}x^{(0)} - \frac{1}{2}\sum_{i}(\frac{1}{2})^{i} = lim_{k
\rightarrow \infty}(\frac{1}{2})^{k+1} = 0 = x^\star,

i.e. convergence actually does take place. Furthermore recognize that this example actually does satisfy condition (6) as

(6.3) \quad  \sigma^{(k)} = (\frac{1}{2})^{(k+1)} \geq -c_{2}
\frac{2x^{(k)}(-1)}{1} = c_{2}\cdot 2(\frac{1}{2})^{k}  
\Leftrightarrow \frac{1}{4} \geq c_{2} >0.

Choosing the Direction d[edit]

We have already argued that the choice of \sigma^{(k)} and d^{(k)} is intertwined. Hence the choice of the "right" d^{(k)} is always contingent on the respective stepsize \sigma^{(k)}. So what does "right" mean in this context? Above we showed in equation (8) that choosing an efficient stepsize implied

 (8') \quad lim_{k \rightarrow \infty} -c (\frac{Df(x^{(k)})^{T}d^{(k)}}{|| d^{(k)}||})^{2} = lim_{k \rightarrow \infty} \frac{Df(x^{(k)})^{T}d^{(k)}}{|| d^{(k)}||} = 0.

The "right" direction vector will therefore guarantee that (8') implies that

 (9) \quad lim_{k \rightarrow \infty} Df(x^{(k)}) = 0

as (9) is the condition for the chosen sequence  \{x^{(k)} \}_{k} to converge. So let us explore what directions could be chosen to yield (9). Assume that the stepsize \sigma_{k} is efficient and define

(10) \quad  \beta^{(k)} = \frac{Df(x^{(k)})^{T}d^{(k)}}{|| Df(x^{(k)})|| ||d^{(k)}||} \quad \Leftrightarrow \quad \beta^{(k)}|| Df(x^{(k)})|| = \frac{Df(x^{(k)})^{T}d^{(k)}}{|| d^{(k)}||}

By (8') and (10) we know that

(11) \quad lim_{k \rightarrow \infty} \beta^{(k)}|| Df(x^{(k)})|| = 0.

So if we bound \beta^{(k)} from below (i.e. \beta^{(k)} \leq - \delta < 0), (11) implies that

(12) \quad lim_{k \rightarrow \infty} \beta^{(k)}|| Df(x^{(k)})|| = lim_{k \rightarrow \infty} || Df(x^{(k)})|| = lim_{k \rightarrow \infty} Df(x^{(k)}) = 0,

where (12) gives just the condition of the sequence  \{x^{(k)} \}_{k} converging to the solution x^{\star}. As (10) defines the direction vector  d^{(k)} implicitly by  \beta^{(k)} , the requirements on  \beta^{(k)} translate directly into requirements on  d^{(k)} .

Why Gradient Methods?[edit]

When considering the conditions on  \beta^{(k)} it is clear where the term Gradient Methods originates from. With  \beta^{(k)} given by

 \beta_{k} = \frac{D(f(x)) d^{(k)}}{|| Df(x^{(k)}) || || d^{(k)} ||} = cos(Df(x^{(k)}),d^{(k)})

we have the following result

Given that \sigma^{(k)} was chosen efficiently and d^{(k)} satisfies

(13) \quad cos(Df(x^{(k)}),d^{(k)}) = \beta_{k} \leq - \delta < 0

we have

(14) \quad lim_{k \rightarrow \infty} Df(x^{(k)}) \rightarrow 0

Hence: Convergence takes place if the angle between the negative gradient at x^{(k)} and the direction d^{(k)} is consistently smaller than the right angle. Methods relying on d^{(k)} satisfying (13) are called Gradient Methods.

In other words: As long as one is not moving orthogonal to the gradient and if the stepsize is chosen efficiently, Gradient Methods guarantee convergence to the solution x^{\star}.

Some Specific Algorithms in the Class of Gradient Methods[edit]

Let us now explore three specific algorithms of this class that differ in their respective choice of d^{(k)}.

The Newtonian Method[edit]

The Newtonian Method is by far the most popular method in the field. It is a well known method to solve for the roots of all types of equations and hence can be easily applied to optimization problems as well. The main idea of the Newtonian method is to linearize the system of equations to arrive at

(15) \quad g(x) = g(\hat{x}) + Dg(\hat{x})^{T}(x-\hat{x}) =
0.

(15) can easily be solved for x as the solution is just given by (assuming Dg(\hat{x})^{T} to be non-singular)

(16) \quad x = \hat{x} - [Dg(\hat{x})^{T}]^{-1}g(\hat{x}).

For our purposes we just choose g(x) to be the gradient Df(x) and arrive at

 (17) \quad d_{N}^{(k)} = x^{(k+1)} - x^{(k)} = - [D^2f(x^{(k)})]^{-1}Df(x^{(k)})

where  d_{N}^{(k)} is the so-called Newtonian Direction.

Properties of the Newtonian Method[edit]

Analyzing (17) elicits the main properties of the Newtonian method:

  • The Newtonian Method uses local information of the first and second derivative to calculate d_{N}^{k}.
  • As

 
(18) \quad x^{(k+1)} = x^{(k)} + d_{N}^{(k)}

the Newtonian Method uses a fixed stepsize of  \sigma^{(k)} = 1 . Hence the Newtonian method is not necessarily a descending method in the sense of Lemma 1. The reason is that the fixed stepsize  \sigma^{(k)} = 1 might be larger than the critical stepsize  \bar{\sigma_{k}} given in Lemma 1. Below we provide the Rosenbrock function as an example where the Newtonian Method is not descending.

  • The Method can be time-consuming as calculating  [D^2f(x^{(k)})]^{-1} for every step k can be cumbersome. In applied work one could think about approximations. One could for example update the Hessian only every sth step or one could rely on local approximations. This is known as the Quasi-Newtonian-Method and will be discussed in the section about Variable Metric Methods.
  • To ensure the method to be decreasing one could use an efficient stepsize   \sigma_{E}^{(k)} and set

(19) \quad x^{(k+1)} = x^{(k)} - \sigma_{E}^{(k)}d_{N}^{(k)} = x^{(k)} - \sigma_{E}^{(k)} [D^2 f(x^{k})]^{-1} Df(x^{(k)})

Method of Steepest Descent[edit]

Another frequently used method is the Method of Steepest Descent. The idea of this method is to choose the direction d^{(k)} so that the decrease in the function value f is maximal. Although this procedure seems at a first glance very sensible, it suffers from the fact that it uses effectively less information than the Newtonian Method by ignoring the Hessian's information about the curvature of the function. Especially in the applications below we will see a couple of examples of this problem.

The direction vector of the Method of Steepest Descent is given by

 (20) \quad d_{SD}^{(k)} = argmax_{d : ||d|| = r} \{-Df(x^{(k)})^{T}d \} = argmin_{d : ||d|| = r} \{Df(x^{(k)})^{T}d
\}  = -r \frac{Df(x)}{|| Df(x) ||}

Proof: By the Cauchy-Schwartz Inequality it follows that

 (21) \quad \frac{Df(x)^{T}d}{|| Df(x) || ||d||} \geq -1 \quad \Leftrightarrow \quad Df(x)^{T}d \geq -r || Df(x) ||.

Obviously (21) holds with equality for d^{(k)} = d_{SD}^{(k)} given in (20).

Note especially that for r = || Df(x) || we have d_{SD}^{(k)} = - Df(x^{(k)}), i.e. we just "walk" in the direction of the negative gradient. In contrast to the Newtonian Method the Method of Steepest Descent does not use a fixed stepsize but chooses an efficient stepsize \sigma_{E}^{(k)}. Hence the Method of Steepest Descent defines the sequence  \{x^{(k)} \}_{k} by

 (22) \quad x^{(k+1)} = x^{(k)} + \sigma_{E}^{(k)} d_{SD}^{(k)},

where \sigma_{E}^{(k)} is an efficient stepsize and d_{SD}^{(k)} the Direction of Steepest Descent given in (20).

Properties of the Method of Steepest Descent[edit]
  • With d_{SD}^{(k)} = -r \frac{Df(x)}{|| Df(x)||} the Method of Steepest Descent defines a direction of descent in the sense of Lemma 1, as

Df(x)^{T}d_{SD}^{(k)} = Df(x)^{T}(-r \frac{Df(x)}{|| Df(x)||}) = - \frac{r}{|| Df(x)||}Df(x)^{T}Df(x) < 0.

  • The Method of Steepest Descent is only locally sensible as it ignores second order information.
  • Especially when the criterion function is flat (i.e. the solution x^\star lies in a "valley") the sequence defined by the Method of Steepest Descent fluctuates wildly (see the applications below, especially the example of the Rosenbrock function).
  • As it does not need the Hessian, calculation and implementation of the Method of Steepest Descent is easy and fast.

Variable Metric Methods[edit]

A more general approach than both the Newtonian Method and the Method of Steepest Descent is the class of Variable Metric Methods. Methods in this class rely on the updating formula

 (23) \quad x^{k+1} = x^{k} - \sigma_{E}^{(k)} [A^{k}]^{-1} Df(x^{k}).

If A^{k} is a symmetric and positive definite matrix, (23) defines a descending method as [A^{k}]^{-1} is positive definite if and only if A^{k} is positive definite as well. To see this: just consider the spectral decomposition

 (24) \quad A^{k} = \Gamma \Lambda \Gamma^{T}

where \Gamma and \Lambda are the matrices with eigenvectors and eigenvalues respectively. If  A^{k} is positive definite, all eigenvalues \lambda_{i} are strictly positive. Hence their inverse \lambda_{i}^{-1} are positive as well, so that [A^{k}]^{-1} = \Gamma \Lambda^{-1} \Gamma^{T} is clearly positive definite. But then, substitution of d^{(k)} = [A^{k}]^{-1} Df(x^{k}) yields

 (25) \quad Df(x^{k})^{T}d^{(k)} = -Df(x^{k})^{T}[A^{k}]^{-1}Df(x^{k}) \equiv - v^{T} [A^{k}]^{-1} v \leq 0,

i.e. the method is indeed descending. Up to now we have not specified the matrix A^{k}, but is easily seen that for two specific choices, the Variable Metric Method just coincides with the Method of Steepest Descent and the Newtonian Method respectively.

 (22') \quad x^{k+1} = x^{k} - \sigma_{E}^{(k)} Df(x^{k})

which is just the Method of Steepest Descent.

  • For A^{k} = D^{2}f(x^{k}) it follows that

 (19') \quad x^{k+1} = x^{k} - \sigma_{E}^{(k)} [D^{2}f(x^{k})]^{-1}Df(x^{k})

which is just the Newtonian Method using a stepsize \sigma_{E}^{(k)}.

The Quasi Newtonian Method[edit]

A further natural candidate for a Variable Metric Method is the Quasi Newtonian Method. In contrast to the standard Newtonian Method it uses an efficient stepsize so that it is a descending method and in contrast to the Method of Steepest Descent it does not fully ignore the local information about the curvature of the function. Hence the Quasi Newtonian Method is defined by the two requirements on the matrix A^{k}:

  • A^{k} should approximate the Hessian D^{2}f(x^{k}) to make use of the information about the curvature and
  • the update A^{k} \rightarrow A^{k+1} should be easy so that the algorithm is still relatively fast (even in high dimensions).

To ensure the first requirement, A^{k+1} should satisfy the so-called Quasi-Newtonian-Equation

 (26) \quad A^{k+1}(x^{(k+1)} - x^{(k)}) = Df(x^{(k+1)})-Df(x^{(k)})

as all A^{k} satisfying (26) reflect information about the Hessian. To see this, consider the function g(x) defined as

 (27) \quad g(x) = f(x^{k+1})+Df(x^{k+1})^{T}(x - x^{k+1})+\frac{1}{2}(x-x^{k+1})^{T}A^{k+1}(x - x^{k+1}).

Then it is obvious that g(x^{k+1}) = f(x^{k+1}) and Dg(x^{k+1}) = Df(x^{k+1}). So g(x) and f(x) are reasonably similar in the neighborhood of x^{(k+1)}. In order to ensure that g(x) is also a good approximation at x^{(k)}, we want to choose A^{k+1} such that the gradients at x^{(k)} are identical. With

(28) \quad Dg(x^{k}) = Df(x^{k+1}) - A^{k+1} (x^{k+1} - x^{k})

it is clear that Dg(x^{k}) = Df(x^{k}) if  A^{k+1} satisfies the Quasi Newtonian Equation given in (26). But then it follows that

 (29) \quad A^{k+1} (x^{k+1} - x^{k}) = Df(x^{k+1}) - Dg(x^{k}) = Df(x^{k+1}) - Df(x^{k}) = D^2 f(\lambda x^{(k)} + (1-\lambda)x^{(k+1)})(x^{k+1} - x^{k}).

Hence as long as x^{(k+1)} and x^{(k)} are not too far apart, A^{k+1} satisfying (26) is a good approximation of D^2 f(x^{(k)}).

Let us now come to the second requirement that the update of the A^{k} should be easy. One specific algorithm to do so is the so-called BFGS-Algorithm. The main merit of this algorithm is the fact that it uses only the already calculated elements \{x^{(k)}\}_{k} and \{Df(x^{(k)})\}_{k} to construct the update A^{(k+1)}. Hence no new entities have to be calculated but one has only to keep track of the x-sequence and sequence of gradients. As a starting point for the BFGS-Algorithm one can provide any positive definite matrix (e.g. the identity matrix or the Hessian at x^{(0)}). The BFGS-Updating-Formula is then given by

 (30) \quad A^{k} = A^{k-1} -
\frac{(A^{k-1})^{T}\gamma_{k-1}^{T}\gamma_{k-1}A^{k-1}}{\gamma_{k-1}^{T}A^{k-1}\gamma_{k-1}} + \frac{\Delta_{k-1}\Delta_{k-1}^{T}}{\Delta_{k-1}^{T}\gamma_{k-1}}

where \Delta_{k-1} = Df(x^{(k)}) - Df(x^{(k-1)}) and \gamma_{k-1} = x^{(k)} - x^{(k-1)}. Furthermore (30) ensures that all A^{k} are positive definite as required by Variable Metric Methods to be descending.

Properties of the Quasi Newtonian Method[edit]
  • It uses second order information about the curvature of f(x) as the matrices A^{k} are related to the Hessian D^{2}f(x).
  • Nevertheless it ensures easy and fast updating (e.g. by the BFGS-Algorithm) so that it is faster than the standard Newtonian Method.
  • It is a descending method as A^{k} are positive definite.
  • It is relatively easy to implement as the BFGS-Algorithm is available in most numerical or statistical software packages.

Applications[edit]

To compare the methods and to illustrate the differences between the algorithms we will now evaluate the performance of the Steepest Descent Method, the standard Newtonian Method and the Quasi Newtonian Method with an efficient stepsize. We use two classical functions in this field, namely the Himmelblau and the Rosenbrock function.

Application I: The Himmelblau Function[edit]

The Himmelblau function is given by

 (31) \quad f(x,y) = (x^2 + y - 11)^2 + (x + y^2 - 7)^2

This fourth order polynomial has four minima, four saddle points and one maximum so there are enough possibilities for the algorithms to fail. In the following pictures we display the contour plot and the 3D plot of the function for different starting values.

In Figure 1 we display the function and the paths of all three methods at a starting value of (2, -4). Obviously the three methods do not find the same minimum. The reason is of course the different direction vector of the Method of Steepest Descent - by ignoring the information about the curvature it chooses a totally different direction than the two Newtonian Methods (see especially the right panel of Figure 1).

Figure 1: The two Newton Methods converge to the same, the Method of Steepest Descent to a different minimum.

Consider now the starting value (4.5, -0.5), displayed in Figure 2. The most important thing is of course that now all methods find different solutions. That the Method of Steepest Descent finds a different solution than the two Newtonian Methods is again not that surprising. But that the two Newtonian Methods converge to different solution shows the significance of the stepsize \sigma. With the Quasi-Newtonian Method choosing an efficient stepsize in the first iteration, both methods have different stepsizes and direction vectors for all iterations after the first one. And as seen in the picture: the consequence may be quite significant.

Figure 2: Even all methods find different solutions.

Application II: The Rosenbrock Function[edit]

The Rosenbrock function is given by

 (32) \quad f(x,y) = 100(y - x^2)^2 + (1-x)^2 \

Although this function has only one minimum it is an interesting function for optimization problems. The reason is the very flat valley of this U-shaped function (see the right panels of Figures 3 and 4). Especially for econometricians this function may be interesting because in the case of Maximum Likelihood estimation flat criterion functions occur quite frequently. Hence the results displayed in Figures 3 and 4 below seem to be rather generic for functions sharing this problem.

My experience when working with this function and the algorithms I employed is that Figure 3 (given a starting value of (2,-5)) seems to be quite characteristic. In contrast to the Himmelblau function above, all algorithms found the same solution and given that there is only one minimum this could be expected. More important is the path the different methods choose as is reflects the different properties of the respective methods. It is seen that the Method of Steepest Descent fluctuates rather wildly. This is due to the fact that it does not use information about the curvature but rather jumps back and forth between the "hills" adjoining the valley. The two Newtonian Methods choose a more direct path as they use the second order information. The main difference between the two Newtonian Methods is of course the stepsize. Figure 3 shows that the Quasi Newtonian Method uses very small stepsizes when working itself through the valley. In contrast, the stepsize of the Newtonian Method is fixed so that it jumps directly in the direction of the solution. Although one might conclude that this is a disadvantage of the Quasi Newtonian Method, note of course that in general these smaller stepsizes come with benefit of a higher stability, i.e. the algorithm is less likely to jump to a different solution. This can be seen in Figure 4.

Figure 3: All methods find the same solution, but the Method of Steepest Descent fluctuates heavily.

Figure 4, which considers a starting value of (-2,-2), shows the main problem of the Newtonian Method using a fixed stepsize - the method might "overshoot" in that it is not descending. In the first step, the Newtonian Method (displayed as the purple line in the figure) jumps out of the valley to only bounce back in the next iteration. In this case convergence to the minimum still occurs as the gradient at each side points towards the single valley in the center, but one can easily imagine functions where this is not the case. The reason of this jump are the second derivatives which are very small so that the step [Df(x^{(k)})]^{-1} Df(x^{(k)})) gets very large due to the inverse of the Hessian. In my experience I would therefore recommend to use efficient stepsizes to have more control over the paths the respective Method chooses.

Figure 2: Overshooting of the Newtonian Method due to the fixed stepsize.

Application III: Maximum Likelihood Estimation[edit]

For econometricians and statisticians the Maximum Likelihood Estimator is probably the most important application of numerical optimization algorithms. Therefore we will briefly show how the estimation procedure fits in the framework developed above.

As usual let

(33) \quad f(Y | X; \theta)

be the conditional density of Y given X with parameter \theta and

(34) \quad l(\theta; Y | X)

the conditional likelihood function for the parameter  \theta

If we assume the data to be independently, identically distributed (iid) then the sample log-likelihood follows as

(35) \quad \mathcal{L}(\theta; Y_{1}, ..., Y_{N}) = \sum_{i}^{N} \mathcal{L}(\theta; Y_{i}) = \sum_{i}^{N} log(l(\theta; Y_{i})).

Maximum Likelihood estimation therefore boils down to maximize (35) with respect to the parameter  \theta . If we for simplicity just decide to use the Newtonian Method to solve that problem, the sequence  \{ \theta^{(k)} \}_{k} is recursively defined by

(36) \quad D_{\theta}\mathcal{L}(\theta^{(k+1)}) = D_{\theta}\mathcal{L}(\theta^{(k)}) + D_{\theta \theta}\mathcal{L}(\theta^{(k)})(\theta^{(k+1)} -\theta^{(k)}) = 0 \Leftrightarrow \theta^{(k+1)} = \theta^{(k)} - [D_{\theta \theta}\mathcal{L}(\theta^{(k)})]^{-1}D_{\theta}\mathcal{L}(\theta^{(k)})


where D_{\theta}\mathcal{L} and D_{\theta \theta}\mathcal{L} denotes the first and second derivative with respect to the parameter vector \theta and  [D_{\theta \theta} \mathcal{L}(\theta^{(k)})]^{-1}D_{\theta} \mathcal{L}(\theta^{(k)}) defines the Newtonian Direction given in (17). As Maximum Likelihood estimation always assumes that the conditional density (i.e. the distribution of the error term) is known up to the parameter \theta, the methods described above can readily be applied.

A Concrete Example of Maximum Likelihood Estimation[edit]

Assume a simple linear model

 (37a) \quad Y_{i} = \beta_{1} + \beta_{x} X_{i} + U_{i}

with \theta = (\beta_{1}, \beta_{2})'. The conditional distribution Y is then determined by the one of U, i.e.

 (37b)  \quad p(Y_{i} - \beta_{1} - \beta_{x} X_{i}) \equiv p_{\mid X_{i}}(Y_{i})  = p(U_{i}),

where p denotes the density function. Generally, there is no closed form solution of maximizing (35) (at least if U does not happen to be normally distributed), so that numerical methods have to be employed. Hence assume that U follows Student's t-distribution with m degrees of freedom so that (35) is given by

 (38)  \quad \mathcal{L}(\theta;Y_{\mid X}) = \sum log( \frac{\Gamma(\frac{m+1}{2})}{\sqrt{\pi m}\Gamma(\frac{m}{2})}(1+\frac{(y_{i} - x_{i}^{T}\beta)^2}{m})^{-\frac{m+1}{2}})

where we just used the definition of the density function of the t-distribution. (38) can be simplified to

 (39) \quad \mathcal{L}(\theta;Y_{\mid X}) = N[log(\Gamma(\frac{m+1}{2})) - log(\sqrt{\pi m}\Gamma(\frac{m}{2}))] -\frac{m+1}{2} \sum log(1+\frac{(y_{i} - x_{i}^{T}\beta)^2}{m})

so that (if we assume that the degrees of freedom m are known)

 (40) \quad \textit{argmax} \{ \mathcal{L}(\theta;Y_{\mid X}) \} = \textit{argmax} \{ -\frac{m+1}{2} \sum log(1+\frac{(y_{i} - x_{i}^{T}\beta)^2}{m}) \}  = \textit{argmin} \{ \sum log(1+\frac{(y_{i} - x_{i}^{T}\beta)^2}{m}) \}.

With the criterion function

 (41) \quad  f(\beta_{1}, \beta_{2}) = \sum log(1+\frac{(y_{i} - \beta_{1} - \beta_{2}x_{i})^2}{m})

the methods above can readily applied to calculate the Maximum Likelihood Estimator (\hat{\beta}_{1,ML}, \hat{\beta}_{2,ML}) maximizing (41).

References[edit]

  • Alt, W. (2002): "Nichtlineare Optimierung", Vieweg: Braunschweig/Wiesbaden
  • Härdle, W. and Simar, L. (2003): "Applied Multivariate Statistical Analysis", Springer: Berlin Heidelberg
  • Königsberger, K. (2004): "Analysis I", Springer: Berlin Heidelberg
  • Ruud, P. (2000): "Classical Econometric Theory", Oxford University Press: New York

Quantile Regression[edit]

Quantile Regression as introduced by Koenker and Bassett (1978) seeks to complement classical linear regression analysis. Central hereby is the extension of "ordinary quantiles from a location model to a more general class of linear models in which the conditional quantiles have a linear form" (Buchinsky (1998), p. 89). In Ordinary Least Squares (OLS) the primary goal is to determine the conditional mean of random variable Y, given some explanatory variable x_i, reaching the expected value E[Y|x_i]. Quantile Regression goes beyond this and enables one to pose such a question at any quantile of the conditional distribution function. The following seeks to introduce the reader to the ideas behind Quantile Regression. First, the issue of quantiles is addressed, followed by a brief outline of least squares estimators focusing on Ordinary Least Squares. Finally, Quantile Regression is presented, along with an example utilizing the Boston Housing data set.

Preparing the Grounds for Quantile Regression[edit]

What are Quantiles[edit]

Gilchrist (2001, p.1) describes a quantile as "simply the value that corresponds to a specified proportion of an (ordered) sample of a population". For instance a very commonly used quantile is the median M, which is equal to a proportion of 0.5 of the ordered data. This corresponds to a quantile with a probability of 0.5 of occurrence. Quantiles hereby mark the boundaries of equally sized, consecutive subsets. (Gilchrist, 2001)

More formally stated, let Y be a continuous random variable with a distribution function F_Y(y) such that

 (1)  F_Y(y) = P (Y\leq {y}) = \tau

which states that for the distribution function F_Y(y) one can determine for a given value y the probability \tau of occurrence. Now if one is dealing with quantiles, one wants to do the opposite, that is one wants to determine for a given probability \tau of the sample data set the corresponding value y. A \tau^{th}-quantile refers in a sample data to the probability \tau for a value y.

 (2) F_Y(y_\tau) = \tau

Another form of expressing the \tau^{th}-quantile mathematically is following:

 (3) y_\tau = F_{Y}^{-1}(\tau)

y_\tau is such that it constitutes the inverse of the function F_Y(\tau) for a probability \tau.

Note that there are two possible scenarios. On the one hand, if the distribution function F_Y(y) is monotonically increasing, quantiles are well defined for every \tau \in (0;1). However, if a distribution function F_Y(y) is not strictly monotonically increasing , there are some \taus for which a unique quantile can not be defined. In this case one uses the smallest value that y can take on for a given probability \tau.

Both cases, with and without a strictly monotonically increasing function, can be described as follows:

 (4) y_\tau = F_Y^{-1}(\tau) = inf \left\{ y | F_Y(y) \geq \tau \right\}

That is y_\tau is equal to the inverse of the function F_Y(\tau) which in turn is equal to the infimum of y such that the distribution function F_Y(y) is greater or equal to a given probability \tau, i.e. the \tau^{th}-quantile. (Handl (2000))

However, a problem that frequently occurs is that an empirical distribution function is a step function. Handl (2000) describes a solution to this problem. As a first step, one reformulates equation 4 in such a way that one replaces the continuous random variable Y with n, the observations, in the distribution function F_Y(y), resulting in the empirical distribution function F_n(y). This gives the following equation:

 (5) \hat{y}_\tau = inf \left\{ y | F_n(y) \geq \tau \right\}

The empirical distribution function can be separated into equally sized, consecutive subsets via the the number of observations n. Which then leads one to the following step:

 (6) \hat{y}_\tau = y_{(i)}

with i=1,...,n and y_{(1)},...,y_{(n)} as the sorted observations. Hereby, of course, the range of values that y_\tau can take on is limited simply by the observations y_{(i)} and their nature. However, what if one wants to implement a different subset, i.e. different quantiles but those that can be derived from the number of observations n?

Therefore a further step necessary to solving the problem of a step function is to smooth the empirical distribution function through replacing it a with continuous linear function \tilde{F}(y). In order to do this there are several algorithms available which are well described in Handl (2000) and more in detail with an evaluation of the different algorithms and their efficiency in computer packages in Hyndman and Fan (1996). Only then one can apply any division into quantiles of the data set as suitable for the purpose of the analysis. (Handl (2000))

Ordinary Least Squares[edit]

In regression analysis the researcher is interested in analyzing the behavior of a dependent variable y_i given the information contained in a set of explanatory variables x_i. Ordinary Least Squares is a standard approach to specify a linear regression model and estimate its unknown parameters by minimizing the sum of squared errors. This leads to an approximation of the mean function of the conditional distribution of the dependent variable. OLS achieves the property of BLUE, it is the best, linear, and unbiased estimator, if following four assumptions hold:

1. The explanatory variable x_i is non-stochastic

2. The expectations of the error term \epsilon_i are zero, i.e. E[\epsilon_i]=0

3. Homoscedasticity - the variance of the error terms \epsilon_i is constant, i.e. var(\epsilon_i)=\sigma^{2}

4. No autocorrelation, i.e. cov(\epsilon_i , \epsilon_j )=0 , i\neq j

However, frequently one or more of these assumptions are violated, resulting in that OLS is not anymore the best, linear, unbiased estimator. Hereby Quantile Regression can tackle following issues: (i), frequently the error terms are not necessarily constant across a distribution thereby violating the axiom of homoscedasticity. (ii) by focusing on the mean as a measure of location, information about the tails of a distribution are lost. (iii) OLS is sensitive to extreme outliers that can distort the results significantly. (Montenegro (2001))

Quantile Regression[edit]

The Method[edit]

Quantile Regression essentially transforms a conditional distribution function into a conditional quantile function by slicing it into segments. These segments describe the cumulative distribution of a conditional dependent variable Y given the explanatory variable x_i with the use of quantiles as defined in equation 4.

For a dependent variable Y given the explanatory variable X=x and fixed \tau, 0<\tau<1, the conditional quantile function is defined as the \tau-th quantile Q_{Y|X}(\tau|x) of the conditional distribution function F_{Y|X}(y|x). For the estimation of the location of the conditional distribution function, the conditional median Q_{Y|X}(0,5|x) can be used as an alternative to the conditional mean. (Lee (2005))

One can nicely illustrate Quantile Regression when comparing it with OLS. In OLS, modeling a conditional distribution function of a random sample ({y_1,...,y_n}) with a parametric function \mu(x_i,\beta) where x_i represents the independent variables, \beta the corresponding estimates and \mu the conditional mean, one gets following minimization problem:

 (7) min_{\beta\in\Re}\sum_{i=1}^{n}(y_i-\mu(x_i,\beta))^{2}

One thereby obtains the conditional expectation function E[Y|x_i]. Now, in a similar fashion one can proceed in Quantile Regression. Central feature thereby becomes \rho_\tau, which serves as a check function.

 (8)
\rho_{\tau}(x)=\begin{cases}\tau*x & \mbox{if } x \ge 0 
\\ (\tau-1)*x & \mbox{if } x < 0 \end{cases}

This check-function ensures that

1. all \rho_\tau are positive

2. the scale is according to the probability \tau

Such a function with two supports is a must if dealing with L1 distances, which can become negative.

In Quantile Regression one minimizes now following function:

 (9) min_{\beta\in\Re}\sum_{i=1}^{n}\rho_{\tau}(y_i-\xi(x_i,\beta))

Here, as opposed to OLS, the minimization is done for each subsection defined by \rho_\tau, where the estimate of the \tau^{th}-quantile function is achieved with the parametric function \xi(x_i, \beta). (Koenker and Hallock (2001))

Features that characterize Quantile Regression and differentiate it from other regression methods are following:

1. The entire conditional distribution of the dependent variable Y can be characterized through different values of \tau

2. Heteroscedasticity can be detected

3. If the data is heteroscedastic, median regression estimators can be more efficient than mean regression estimators

4. The minimization problem as illustrated in equation 9 can be solved efficiently by linear programming methods, making estimation easy

5. Quantile functions are also equivariant to monotone transformations. That is Q_{h(Y|X)}(x_\tau)=h(Q_{(Y|X)}(x_{\tau})), for any function

6. Quantiles are robust in regards to outliers ( Lee (2005) )

A graphical illustration of Quantile Regression[edit]

Before proceeding to a numerical example, the following subsection seeks to graphically illustrate the concept of Quantile Regression. First, as a starting point for this illustration, consider figure 1. For a given explanatory value of x_i the density for a conditional dependent variable Y is indicated by the size of the balloon. The bigger the balloon, the higher is the density, with the mode, i.e. where the density is the highest, for a given x_i being the biggest balloon. Quantile Regression essentially connects the equally sized balloons, i.e. probabilities, across the different values of x_i, thereby allowing one to focus on the interrelationship between the explanatory variable x_i and the dependent variable Y for the different quantiles, as can be seen in figure 2. These subsets, marked by the quantile lines, reflect the probability density of the dependent variable Y given x_i.

Figure 1: Probabilities of occurrence for individual explanatory variables

The example used in figure 2 is originally from Koenker and Hallock (2000), and illustrates a classical empirical application, Ernst Engel's (1857) investigation into the relationship of household food expenditure, being the dependent variable, and household income as the explanatory variable. In Quantile Regression the conditional function of Q_{Y|X}(\tau|x) is segmented by the \tau^{th}-quantile. In the analysis, the \tau^{th}-quantiles \tau \in\left\{0,05; 0,1; 0,25; 0,5; 0,75; 0,9; 0,95\right\}, indicated by the thin blue lines that separate the different color sections, are superimposed on the data points. The conditional median (\tau=0,5) is indicated by a thick dark blue line, the conditional mean by a light yellow line. The color sections thereby represent the subsections of the data as generated by the quantiles.

Figure 2: Engels Curve, with the median highlighted in dark blue and the mean in yellow

Figure 2 can be understood as a contour plot representing a 3-D graph, with food expenditure and income on the respective y and x axis. The third dimension arises from the probability density of the respective values. The density of a value is thereby indicated by the darkness of the shade of blue, the darker the color, the higher is the probability of occurrence. For instance, on the outer bounds, where the blue is very light, the probability density for the given data set is relatively low, as they are marked by the quantiles 0,05 to 0,1 and 0,9 to 0,95. It is important to notice that figure 2 represents for each subsections the individual probability of occurrence, however, quantiles utilize the cumulative probability of a conditional function. For example, \tau of 0,05 means that 5\% of observations are expected to fall below this line, a \tau of 0,25 for instance means that 25\% of the observations are expected to fall below this and the 0,1 line.

The graph in figure 2, suggests that the error variance is not constant across the distribution. The dispersion of food expenditure increases as household income goes up. Also the data is skewed to the left, indicated by the spacing of the quantile lines that decreases above the median and also by the relative position of the median which lies above the mean. This suggests that the axiom of homoscedasticity is violated, which OLS relies on. The statistician is therefore well advised to engage in an alternative method of analysis such as Quantile Regression, which is actually able to deal with heteroscedasticity.

A Quantile Regression Analysis[edit]

In order to give a numerical example of the analytical power of Quantile Regression and to compare it within the boundaries of a statistical application with OLS the following section will be analyzing some selected variables of the Boston Housing dataset which is available at the md-base website. The data was first analyzed by Belsley, Kuh, and Welsch (1980). The original data comprised 506 observations for 14 variables stemming from the census of the Boston metropolitan area.

This analysis utilizes as the dependent variable the median value of owner occupied homes (a metric variable, abbreviated with H) and investigates the effects of 4 independent variables as shown in table 1. These variables were selected as they best illustrate the difference between OLS and Quantile Regression. For the sake of simplicity of the analysis, it was neglected for now to deal with potential difficulties related to finding the correct specification of a parametric model. A simple linear regression model therefore was assumed. For the estimation of asymptotic standard errors see for example Buchinsky (1998), which illustrates the design-matrix bootstrap estimator or alternatively Powell (1986) for kernel based estimation of asymptotic standard errors.

Table1: The explanatory variables
Name Short What it is type
NonrTail T Proportion of non-retail business acres metric
NoorOoms O Average number of rooms per dwelling metric
Age A Proportion of owner-built dwellings prior to 1940 metric
PupilTeacher P Pupil-teacher ratio metric

In the following firstly an OLS model was estimated. Three digits after the comma were indicated in the tables as some of the estimates turned out to be very small.

 (10) E [H_i | T_i, O_i, A_i, P_i] = \alpha + \beta T_i + \delta O_i + \gamma A_i + \lambda P_i

Computing this via XploRe one obtains the results as shown in the table below.

Table2: OLS estimates
\hat{\alpha} \hat{\beta} \hat{\delta} \hat{\gamma} \hat{\lambda}
36,459 0,021 38,010 0,001 -0,953


Analyzing this data set via Quantile Regression, utilizing the \tau^{th} quantiles \tau \in \left(0,1; 0,3; 0,5; 0,7; 0,9\right) the model is characterized as follows:

 (11) Q_H [\tau| T_i, O_i, A_i, P_i] = \alpha_\tau + \beta_\tau T_i  + \delta_\tau O_i  + \gamma_\tau A_i  + \lambda_\tau P_i

Just for illustrative purposes and to further foster the understanding of the reader for Quantile Regression, the equation for the 0,1^{th} quantile is briefly illustrated, all others follow analogous:

 (12) min\left[\rho_{0,1}(y_1-x_1\beta)+\rho_{0,1}(y_2-x_2\beta)+ ...+\rho_{0,1}(y_n-x_n\beta)\right]

 \mbox{ equation 12 with } 
\rho_{0,1}(y_i-x_i\beta)=\begin{cases}0,1(y_i-x_i\beta) & \mbox{if }(y_i-x_i\beta)>0
\\-0,9(y_i-x_i\beta) & \mbox{if }(y_i-x_i\beta)<0 \end{cases}

Table3: Quantile Regression estimates
\tau \hat{\alpha}_\tau \hat{\beta}_\tau \hat{\delta}_\tau \hat{\gamma}_\tau \hat{\lambda}_\tau
0,1 23,442 0,087 29,606 -0,022 -0,443
0,3 15,7130 -0,001 45,281 -0,037 -0,617
0,5 14,8500 0,022 53,252 -0,031 -0,737
0,7 20,7910 -0,021 50,999 -0,003 -0,925
0,9 34,0310 -0,067 51,353 0,004 -1,257

Now if one compares the results for the estimates of OLS from table 2 and Quantile Regression, table 3, one finds that the latter method can make much more subtle inferences of the effect of the explanatory variables on the dependent variable. Of particular interest are thereby quantile estimates that are relatively different as compared to other quantiles for the same estimate.

Probably the most interesting result and most illustrative in regards to an understanding of the functioning of Quantile Regression and pointing to the differences with OLS are the results for the independent variable of the proportion of non-retail business acres (T_i). OLS indicates that this variable has a positive influence on the dependent variable, the value of homes, with an estimate of \hat{\beta}=0,021, i.e. the value of houses increases as the proportion of non-retail business acres (T_i) increases in regards to the Boston Housing data.

Looking at the output that Quantile Regression provides us with, one finds a more differentiated picture. For the 0,1 quantile, we find an estimate of \hat{\beta}_{0,1}= 0,087 which would suggest that for this low quantile the effect seems to be even stronger than is suggested by OLS. Here house prices go up when the proportion of non-retail businesses (T_i) goes up, too. However, considering the other quantiles, this effect is not quite as strong anymore, for the 0,7th and 0,9th quantile this effect seems to be even reversed indicated by the parameter \hat{\beta}_{0,7}= -0,021 and \hat{\beta}_{0,9}= -0,062. These values indicate that in these quantiles the house price is negatively influenced by an increase of non-retail business acres (T_i). The influence of non-retail business acres (T_i) seems to be obviously very ambiguous on the dependent variable of housing price, depending on which quantile one is looking at. The general recommendation from OLS that if the proportion of non-retail business acres (T_i) increases, the house prices would increase can obviously not be generalized. A policy recommendation on the OLS estimate could therefore be grossly misleading.

One would intuitively find the statement that the average number of rooms of a property (O_i) positively influences the value of a house, to be true. This is also suggested by OLS with an estimate of \hat{\delta}=38,099. Now Quantile Regression also confirms this statement, however, it also allows for much subtler conclusions. There seems to be a significant difference between the 0,1 quantile as opposed to the rest of the quantiles, in particular the 0,9th quantile. For the lowest quantile the estimate is \hat{\delta}_{0,1}= 29,606, whereas for the 0,9th quantile it is \hat{\delta}_{0,9}=51,353. Looking at the other quantiles one can find similar values for the Boston housing data set as for the 0,9th, with estimates of \hat{\delta}_{0,3}=45,281, \hat{\delta}_{0,5}=53,252, and \hat{\delta}_{0,7}=50,999 respectively. So for the lowest quantile the influence of additional number of rooms (O_i) on the house price seems to be considerably smaller then for all the other quantiles.

Another illustrative example is provided analyzing the proportion of owner-occupied units built prior to 1940 (A_i) and its effect on the value of homes. Whereas OLS would indicate this variable has hardly any influence with an estimate of \hat{\gamma}=0,001, looking at Quantile Regression one gets a different impression. For the 0,1th quantile, the age has got a negative influence on the value of the home with \hat{\gamma}_{0,1}=-0,022. Comparing this with the highest quantile where the estimate is \hat{\gamma}_{0,9}=0,004, one finds that the value of the house is suddenly now positively influenced by its age. Thus, the negative influence is confirmed by all other quantiles besides the highest, the 0,9th quantile.

Last but not least, looking at the pupil-teacher ratio (P_i) and its influence on the value of houses, one finds that the tendency that OLS indicates with a value of \hat{\lambda}=-0,953 to be also reflected in the Quantile Regression analysis. However, in Quantile Regression one can see that the influence on the housing price of the pupils-teacher ratio (P_i) gradually increases over the different quantiles, from the 0,1th quantile with an estimate of \hat{\lambda}_{0,1}=-0,443 to the 0,9th quantile with a value of \hat{\lambda}_{0,9}=-1,257.

This analysis makes clear, that Quantile Regression allows one to make much more differentiated statements when using Quantile Regression as opposed to OLS. Sometimes OLS estimates can even be misleading what the true relationship between an explanatory and a dependent variable is as the effects can be very different for different subsection of the sample.

Conclusion[edit]

For a distribution function F_Y (y) one can determine for a given value of y the probability \tau of occurrence. Now quantiles do exactly the opposite. That is, one wants to determine for a given probability \tau of the sample data set the corresponding value y. In OLS, one has the primary goal of determining the conditional mean of random variable Y, given some explanatory variable x_i , E[Y|x_i]. Quantile Regression goes beyond this and enables us to pose such a question at any quantile of the conditional distribution function. It focuses on the interrelationship between a dependent variable and its explanatory variables for a given quantile. Quantile Regression overcomes thereby various problems that OLS is confronted with. Frequently, error terms are not constant across a distribution, thereby violating the axiom of homoscedasticity. Also, by focusing on the mean as a measure of location, information about the tails of a distribution are lost. And last but not least, OLS is sensitive to extreme outliers, which can distort the results significantly. As has been indicated in the small example of the Boston Housing data, sometimes a policy based upon an OLS analysis might not yield the desired result as a certain subsection of the population does not react as strongly to this policy or even worse, responds in a negative way, which was not indicated by OLS.


References[edit]

Abrevaya, J. (2001): “The effects of demographics and maternal behavior on the distribution of birth outcomes,” in Economic Application of Quantile Regression, ed. by B. Fitzenberger, R. Koenker, and J. A. Machade, pp. 247–257. Physica-Verlag Heidelberg, New York.

Belsley, D. A., E. Kuh, and R. E. Welsch (1980): Applied Multivariate Statistical Analysis. Regression Diagnostics, Wiley.

Buchinsky, M. (1998): “Recent Advances in Quantile Regression Models: A Practical Guidline for Empirical Research,” Journal of Human Resources, 33(1), 88–126.

Cade, B.S. and B.R. Noon (2003): A gentle introduction to quantile regression for ecologists. Frontiers in Ecology and the Environment 1(8): 412-420. http://www.fort.usgs.gov/products/publications/21137/21137.pdf

Cizek, P. (2003): “Quantile Regression,” in XploRe Application Guide, ed. by W. Härdle, Z. Hlavka, and S. Klinke, chap. 1, pp. 19–48. Springer, Berlin.

Curry, J., and J. Gruber (1996): “Saving Babies: The Efficacy and Costs of Recent Changes in the Medicaid Eligibility of Pregnant Women,” Journal of Political Economy, 104, 457–470.

Handl, A. (2000): “Quantile,” available at http://www.wiwi.uni-bielefeld.de/~frohn/Lehre/Datenanalyse/Skript/daquantile.pdf

Härdle, W. (2003): Applied Multivariate Statistical Analysis. Springer Verlag, Heidelberg. Hyndman, R. J., and Y. Fan (1996): “Sample Quantiles in Statistical Packages,” The American Statistician, 50(4), 361 – 365.

Jeffreys, H., and B. S. Jeffreys (1988): Upper and Lower Bounds. Cambridge University Press.

Koenker, R., and G. W. Bassett (1978): “Regression Quantiles,” Econometrica, 46, 33–50.

Koenker, R., and G. W. Bassett (1982): “Robust tests for heteroscedasticity based on Regression Quantiles,” Econometrica, 61, 43–61.

Koenker, R., and K. F. Hallock (2000): “Quantile Regression an Introduction,” available at http://www.econ.uiuc.edu/~roger/research/intro/intro.html

Koenker, R., and K. F. Hallock (2001): “Quantile Regression,” Journal of Economic Perspectives, 15(4), 143–156.

Lee, S. (2005): “Lecture Notes for MECT1 Quantile Regression,” available at http://www.homepages.ucl.ac.uk/~uctplso/Teaching/MECT/lecture8.pdf

Lewit, E. M., L. S. Baker, H. Corman, and P. Shiono (1995): “The Direct Costs of Low Birth Weight,” The Future of Children, 5, 35–51.

mdbase (2005): “Statistical Methodology and Interactive Datanalysis,” available at http://www.quantlet.org/mdbase/

Montenegro, C. E. (2001): “Wage Distribution in Chile: Does Gender Matter? A Quantile Regression Approach,” Working Paper Series 20, The World Bank, Development Research Group.

Powell, J. (1986): “Censored Regression Quantiles,” Journal of Econometrics, 32, 143– 155.

Scharf, F. S., F. Juanes, and M. Sutherland (1998): “Inferring Ecologiocal Relationships from the Edges of Scatter Diagrams: Comparison of Regression Techniques,” Ecology, 79(2), 448–460.

XploRe (2006): “XploRe,” available at http://www.xplore-stat.de/index_js.html

Numerical Comparison of Statistical Software[edit]

Introduction[edit]

Statistical computations require an extra accuracy and are open to some errors such as truncation or cancellation error etc. These errors occur as a result of binary representation and finite precision and may cause inaccurate results. In this work we are going to discuss the accuracy of the statistical software, different tests and methods available for measuring the accuracy and the comparison of different packages.

Accuracy of Software[edit]

Accuracy can be defined as the correctness of the results. When a statistical software package is used, it is assumed that the results are correct in order to comment on these results. On the other hand it must be accepted that computers have some limitations. The main problem is that the available precision provided by computer systems is limited. It is clear that statistical software can not deliver such accurate results, which exceed these limitations. However statistical software should recognize its limits and give clear indication that these limits are reached. We have two types of precision generally used today:

  • Single precision
  • Double precision

Binary Representation and Finite Precision[edit]

As we discussed above under the problem of software accuracy lay the binary representation and finite precision. In computer we don’t have real numbers. But we represent them with a finite approximation.

Example: Assume that we want to represent 0.1 in single precision. The result will be as follows:

0.1 = .00011001100110011001100110 = 0.99999964 (McCullough,1998)

It is clear that we can only approximate to 0.1 in binary form. This problem grows, if we try to subtract two large numbers which differs only in the decimals. For instance 100000.1-100000 = .09375

With single precision we can only represent 24 significant binary digits, with other word 6-7 decimal digits. In double precision it is possible to represent 53 significant binary digits and 15-17 significant decimal digits. Limitations of binary representation create five distinct numerical ranges, which cause the loss of accuracy:

  • negative overflow
  • negative underflow
  • zero
  • positive underflow
  • positive overflow

Overflow means that values have grown too large for the representation. Underflow means that values are so small and so close to zero that causes to set to zero. Single and double precision representations have different ranges.

Results of Binary Representation[edit]

This limitations cause different errors in different situations:

  • Cancellation error results from subtracting two nearly equal numbers.
  • Accumulation errors are successive rounding errors in a series of calculations summed up to a total error. In this type of errors it is possible that only the rightmost digits of the result is affected or the result has no single accurate digits.
  • Another result of binary representation and finite precision is that two formulas which are algebraically equivalent may not be equivalent numerically. For instance:
\sum_{n=1}^{10000} n^{-2} \sum_{n=1}^{10000} (10001-n)^{-2}

First formula adds the numbers in ascending order, whereas the second in descending order. In the first formula the smallest numbers reached at the very end of the computation, so that these numbers are all lost to rounding error. The error is 650 times greater than the second.(McCullough,1998)

  • Truncation error can be defined as approximation error which results from the limitations of binary representation.

Example:

\sin x = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \cdots

Difference between the true value of sin(x) and the result achieved by summing up finite number of terms is truncation error. (McCullough,1998)

  • Algorithmic errors are another reason of inaccuracies. There can be different ways of calculating a quantity and these different methods may be unequally accurate. For example according to Sawitzki (1994) in a single precision environment using the following formula in order to calculate variance :
S^2 = (1/(1-n)(\sum x_i^2 - n \bar x^2))

Measuring Accuracy[edit]

Due to limits of the computers some problems occur in calculating statistical values. We need a measure which shows us the degree of accuracy of a computed value. This measurement base on the difference between the computed value (q) and the real value (c).An oft-used measure is LRE (number of the correct significant digits)(McCullough,1998)

LRE = -\log_{10} {\left[ |q-c|/|c| \right]}

Rules:

  • q should be close to c (less than 2). If they are not, set LRE to zero
  • If LRE is greater than number of the digits in c, set LRE to number of the digits in c.
  • If LRE is less than unity, set it to zero.

Testing Statistical Software[edit]

In this part we are going to discuss two different tests which aim for measuring the accuracy of the software: Wilkinson Test (Wilkinson, 1985) and NIST StRD Benchmarks.

Wilkinson's Statistic Quiz[edit]

Wilkinson dataset “NASTY” which is employed in Wilkinson’s Statistic Quiz is a dataset created by Leland Wilkinson (1985). This dataset consist of different variables such as “Zero” which contains only zeros, “Miss” with all missing values, etc. NASTY is a reasonable dataset in the sense of values it contains. For instance the values of “Big” in “NASTY” are less than U.S. Population or “Tiny” is comparable to many values in engineering. On the other hand the exercises of the “Statistic Quiz” are not meant to be reasonable. These tests are designed to check some specific problems in statistical computing. Wilkinson’s Statistics Quiz is an entry level test.

NIST StRD Benchmarks[edit]

These benchmarks consist of different datasets designed by National Institute of Standards and Technology in different levels of difficulty. The purpose is to test the accuracy of statistical software regarding to different topics in statistics and different level of difficulty. In the webpage of “Statistical Reference Datasets” Project there are five groups of datasets:

  • Analysis of Variance
  • Linear Regression
  • Markov Chain Monte Carlo
  • Nonlinear Regression
  • Univariate Summary Statistics

In all groups of benchmarks there are three different types of datasets: Lower level difficulty datasets, average level difficulty datasets and higher level difficulty datasets. By using these datasets we are going to explore whether the statistical software deliver accurate results to 15 digits for some statistical computations.

There are 11 datasets provided by NIST among which there are six datasets with lower level difficulty, two datasets with average level difficulty and one with higher level difficulty. Certified values to 15 digits for each dataset are provided for the mean (μ), the standard deviation (σ), the first-order autocorrelation coefficient (ρ).

In group of ANOVA-datasets there are 11 datasets with levels of difficulty, four lower, four average and three higher. For each dataset certified values to 15 digits are provided for between treatment degrees of freedom, within treatment. degrees of freedom, sums of squares, mean squares, the F-statistic , the R^2, the residual standard deviation. Since most of the certified values are used in calculating the F-statistic, only its LRE \lambda_F will be compared to the result of regarding statistical software.

For testing the linear regression results of statistical software NIST provides 11 datasets with levels of difficulty two lower, two average and seven higher. For each dataset we have the certified values to 15 digits for coefficient estimates, standard errors of coefficients, the residual standard deviation, R^2, the analysis of variance for linear regression table, which includes the residual sum of squares. LREs for the least accurate coefficients \lambda_\beta, standard errors \lambda_\sigma and Residual sum of squares \lambda_r will be compared. In nonliner regression dataset group there are 27 datasets designed by NIST with difficulty eight lower ,eleven average and eight higher. For each dataset we have certified values to 11 digits provided by NIST for coefficient estimates, standard errors of coefficients, the residual sum of squares, the residual standard deviation, the degrees of freedom.

In the case of calculation of nonlinear regression we apply curve fitting method. In this method we need starting values in order to initialize each variable in the equation. Then we generate the curve and calculate the convergence criterion (ex. sum of squares). Then we adjust the variables to make the curve closer to the data points. There are several algorithms for adjusting the variables:

  • The method of Marquardt and Levenberg
  • The method of linear descent
  • The method of Gauss-Newton

One of these methods is applied repeatedly, until the difference in the convergence criterion is smaller than the convergence tolerance.

NIST provides also two sets of starting values: Start I (values far from solution), Start II (values close to solution). Having Start II as initial values makes it easier to reach an accurate solution. Therefore Start I solutions will be preffered.

Other important settings are as follows:

  • the convergence tolerance (ex. 1E-6)
  • the method of solution (ex. Gauss Newton or Levenberg Marquardt)
  • the convergence criterion (ex. residual sum of squares (RSS) or square of the maximum of the parameter differences)

We can also choose between numerical and analytic derivatives.

Testing Examples[edit]

Testing Software Package: SAS, SPSS and S-Plus[edit]

In this part we are going to discuss the test results of three statistical software packages applied by M.D. McCullough. In McCullough’s work SAS 6.12, SPSS 7.5 and S-Plus 4.0 are tested and compared in respect to certified LRE values provided by NIST. Comparison will be handled according to the following parts:

  • Univariate Statistics
  • ANOVA
  • Linear Regression
  • Nonlinear Regression

Univariate Statistics[edit]

Table 1: Results from SAS for Univariate Statistics (McCullough,1998)

All values calculated in SAS seem to be more or less accurate. For the dataset NumAcc1 p-value can not be calculated because of the insufficient number of observations. Calculating standard deviation for datasets NumAcc3 (average difficulty) and NumAcc 4 (high difficulty) seem to stress SAS.

Table 2: Results from SPSS for Univariate Statistics (McCullough,1998)

All values calculated for mean and standard deviation seem to be more or less accurate. For the dataset NumAcc1 p-value can not be calculated because of the insufficient number of observations.Calculating standard deviation for datasets NumAcc3 and -4 seem to stress SPSS,as well. For p-values SPSS represent results with only 3 decimal digits which causes an understate of first and an overstate of last p-values regarding to accuracy.

Table 3: Results from S-Plus for Univariate Statistics (McCullough,1998)

All values calculated for mean and standard deviation seem to be more or less accurate. S-Plus have also problems in calculating standard deviation for datasets NumAcc3 and -4. S-Plus does not show a good performance in calculating the p-values.

Analysis of Variance[edit]

Table 4: Results from SAS for Analysis of Variance(McCullough,1998)

Results:

  • SAS can solve only the ANOVA problems of lower level difficulty.
  • F-Statistics for datasets of average or higher difficulty can be calculated with very poor performance and zero digit accuracy.
  • SPSS can display accurate results for datasets with lower level difficulty, like SAS.
  • Performance of SPSS in calculating ANOVA is poor.
  • For dataset “AtmWtAg” SPSS displays no F-Statistic which seems more logical instead of displaying zero accurate results.
  • S-Plus handels ANOVA problem better than other softwares.
  • Even for higher difficulty datasets this package can display more accurate results than other. But still results for datasets with high difficulty are not enough accurate.
  • S-Plus can solve the average difficulty problems with a sufficient accuracy.

Linear Regression[edit]

Table 5: Results from SAS for Linear Regression(McCullough,1998)

SAS delivers no solution for dataset Filip which is ten degree polynomial. Except Filip SAS can display more or less accurate results. But the performance seems to decrease for higher difficulty datasets, especially in calculating coefficients

Table 6: Results from SPSS for Linear Regression(McCullough,1998)

SPSS has also Problems with “Filip” which is a 10 degree polynomial. Many packages fail to compute values for it. Like SAS, SPSS delivers lower accuracy for high level datasets

Table 7: Results from S-Plus for Linear Regression(McCullough,1998)

S-Plus is the only package which delivers a result for dataset “Filip”. The accuracy of Result for Filip seem not to be poor but average. Even for higher difficulty datasets S-Plus can calculate more accurate results than other software packages. Only coefficients for datasets “Wrampler4” and “-5” is under the average accuracy.

Nonlinear Regression[edit]

Table 8: Results from SAS for Nonlinear Regression(McCullough,1998)

For the nonlinear Regression two setting combinations are tested for each software, because different settings make a difference in the results.As we can see in the table in SAS preffered combination produce better results than default combination. In this table results produced using default combination are in paranthesis. Because 11 digits are provided for certified values by NIST, we are looking for LRE values of 11.

Preffered combination :

  • Method:Gauss-Newton
  • Criterion: PARAM
  • Tolerance: 1E-6
Table 9: Results from SPSS for Nonlinear Regression(McCullough,1998)

Also in SPSS preffered combination shows a better performance than default options. All problems are solved with initial values “start I” whereas in SAS higher level datasets are solved with Start II values.

Preffered Combination:

  • Method:Levenberg-Marquardt
  • Criterion:PARAM
  • Tolerance: 1E-12
Table 10: Results from S-Plus for Nonlinear Regression(McCullough,1998)

As we can see in the table preffered combination is also in S-Plus better than default combination. All problems except “MGH10” are solved with initial values “start I”. We may say that S-Plus showed a better performance than other software in calculating nonlinear regression.

Preffered Combination:

  • Method:Gauss-Newton
  • Criterion:RSS
  • Tolerance: 1E-6

Results of the Comparison[edit]

All packages delivered accurate results for mean and standard deviation in univariate statistics.There are no big differences between the tested statistical software packages. In ANOVA calculations SAS and SPSS can not pass the average difficulty problems, whereas S-Plus delivered more accurate results than others. But for high difficulty datasets it also produced poor results. Regarding linear regression problems all packages seem to be reliable. If we examine the results for all software packages, we can say that the success in calculating the results for nonlinear regression greatly depends on the chosen options.

Other important results are as follows:

  • S-Plus solved from Start II one time.
  • SPSS never used Start II as initial values, but produce one time zero accurate digits.
  • SAS used Start II three times and produced three times zero accurate digits.

Comparison of different versions of SPSS[edit]

In this part we are going to compare an old version with a new version of SPSS in order to see whether the problems in older version are solved in the new one. In this part we compared SPSS version 7.5 with SPSS version 12.0. LRE values for version 7.5 are taken from an article by B.D. McCullough (see references). We also applied these tests to version 12.0 and calculated regarding LRE values. We chose one dataset from each difficulty groups and applied univariate statistics, ANOVA and linear regression in version 12.0. Source for the datasets is NIST Statistical Reference Datasets Archive. Then we computed LRE values for each dataset by using the certified values provided by NIST in order to compare two versions of SPSS.

Univariate Statistics[edit]

Difficulty: Low

Our first dataset is PiDigits with lower level difficulty which is designed by NIST in order to detect the deficiencies in calculating univariate statistical values.

Certified Values for PiDigits are as follows:

  • Sample Mean : 4.53480000000000
  • Sample Standard Deviation : 2.86733906028871


As we can see in the table 13 the results from SPSS 12.0 match the certified values provided by NIST. Therefore our LREs for mean and standard deviation are \lambda_\mu: 15, \lambda_\delta: 15. In version 7.5 LRE values were \lambda_\mu: 14.7, \lambda_\delta: 15. (McCullough,1998)

Difficulty: Average

Second dataset is NumAcc3 with average difficulty from NIST datasets for univariate statistics. Certified Values for NumAcc3 are as follows:

  • Sample Mean : 1000000.2
  • Sample Standard Deviation : 0.1


In the table 14 we can see that calculated mean value is the same with the certified value by NIST. Therefore our LREs for mean is \lambda_\mu: 15. However the standard deviation value differs from the certified value. So the calculation of LRE for standard deviation is as follows:

\lambda_\delta : -log10 |0,10000000003464-0,1|/|0,1| = 9.5

LREs for SPSS v 7.5 were \lambda_\mu: 15, \lambda_\delta: 9.5. (McCullough,1998)

Difficulty: High

Last dataset in univariate statistics is NumAcc4 with high level of difficulty. Certified Values for NumAcc4 are as follows:

  • Sample Mean : 10000000.2
  • Sample Standard Deviation : 0.1



Also for this dataset we do not have any problems with computed mean value. Therefore LRE is \lambda_\mu: 15. However the standard deviation value does not match to the certified one. So we should calculate the LRE for standard deviation as follows:

\lambda_\delta : -log10 |0,10000000056078-0,1|/|0,1| = 8.3

LREs for SPSS v 7.5 were \lambda_\mu: 15, \lambda_\delta : 8.3 (McCullough,1998)

For this part of our test we can say that there is no difference between two versions of SPSS. For average and high difficulty datasets delivered standard deviation results have still an average accuracy.

Analysis of Variance[edit]

Difficulty: Low

The dataset which we used for testing SPSS 12.0 regarding lower difficulty level problems is SiRstv. Certified F Statistic for SiRstv is 1.18046237440255E+00


  • LRE : \lambda_F: -log10 | 1,18046237440224- 1,18046237440255|/ |1,18046237440255| = 12,58
  • LRE for SPSS v 7.5 : \lambda_F : 9,6 (McCullough, 1998)

Difficulty: Average

Our dataset for average difficulty problems is AtmWtAg . Certified F statistic value for AtmWtAg is 1.59467335677930E+01.


  • LREs : \lambda_F : -log10 | 15,9467336134506- 15,9467335677930|/| 15,9467335677930| = 8,5
  • LREs for SPSS v 7.5 : \lambda_F: miss

Difficulty: High

We used the dataset SmnLsg07 in order to test high level difficulty problems. Certified F value for SmnLsg07 is 2.10000000000000E+01


  • LREs : \lambda_F : -log10 | 21,0381922055595 - 21|/| 21| = 2,7
  • LREs for SPSS v 7.5 : \lambda_F: 0

ANOVA results computed in version 12.0 are better than those calculated in version 7.5. However the accuracy degrees are still too low.

Linear Regression[edit]

Difficulty: Low

Our lower level difficulty dataset is Norris for linear regression. Certified values for Norris are as follows:

  • Sample Residual Sum of Squares  : 26.6173985294224
  • Table 17: Coefficient estimates for Norris(www.itl.nist.gov)
  • LREs : \lambda_r : 9,9 \lambda_\beta : 12,3 \lambda_\sigma : 10,2
  • LREs for SPSS v 7.5 : \lambda_r: 9,9 , \lambda_\beta : 12,3 , \lambda_\sigma : 10,2 (McCullough, 1998)


Difficulty: Average

We used the dataset NoInt1 in order to test the performance in average difficulty dataset. Regression model is as follows:

y = B1*x + e

Certified Values for NoInt1 :

  • Sample Residual Sum of Squares  : 127,272727272727
  • Coefficient estimate : 2.07438016528926, standard deviation : 0.16528925619834E-0(www.itl.nist.gov)
  • LREs: \lambda_r:12,8 \lambda_\beta: 15 \lambda_\sigma: 12,9
  • LREs for SPSS v. 7.5 : \lambda_r: 12,8 , \lambda_\beta: 14,7 , \lambda_\sigma: 12,5 (McCullough, 1998)


Difficulty: High

Our high level difficulty dataset is Longley designed by NIST.

  • Model: y =B0+B1*x1 + B2*x2 + B3*x3 + B4*x4 + B5*x5 + B6*x6 +e
  • LREs :
    • \lambda_r: -log10 |836424,055505842-836424,055505915|/ |836424,055505915| = 13,1
    • \lambda_\beta : 15
    • \lambda_\sigma : -log10 | 0,16528925619836E-01 – 0,16528925619834E-01|/ |0,16528925619834E-01| = 12,9
  • LREs for SPSS v. 7.5 : \lambda_r: 12,8 , \lambda_\beta : 14,7 , \lambda_\sigma : 12,5 (McCullough, 1998)

As we conclude from the computed LREs, there is no big difference between the results of two versions for linear regression.

Conclusion[edit]

By applying these test we try to find out whether the software are reliable and deliver accurate results or not. However based on the results we can say that different software packages deliver different results for same the problem which can lead us to wrong interpretations for statistical research questions.

In specific we can that SAS, SPSS and S-Plus can solve the linear regression problems better in comparision to ANOVA Problems. All three of them deliver poor results for F statistic calculation.

From the results of comparison two different versions of SPSS we can conclude that the difference between the accuracy of the results delivered by SPSS v.12 and v.7.5 is not great considering the difference between the version numbers. On the other hand SPSS v.12 can handle the ANOVA Problems much better than old version. However it has still problems in higher difficulty problems.

References[edit]

  • McCullough, B.D. 1998, 'Assessing The Reliability of Ststistical Software: Part I',The American Statistician, Vol.52, No.4, pp.358-366.
  • McCullough, B.D. 1999, 'Assessing The Reliability of Ststistical Software: Part II', The American Statistician, Vol.53, No.2, pp.149-159
  • Sawitzki, G. 1994, 'Testing Numerical Reliability of Data Analysis Systems', Computational Statistics & Data Analysis, Vol.18, No.2, pp.269-286
  • Wilkinson, L. 1993, 'Practical Guidelines for Testing Statistical Software' in 25th Conference on Statistical Computing at Schloss Reisenburg, ed. P. Dirschedl& R. Ostermnann, Physica Verlag
  • National Institute of Standards and Technology. (1 September 2000). The Statistical Reference Datasets: Archives, [Online], Available from: <http://www.itl.nist.gov/div898/strd/general/dataarchive.html> [10 November 2005].

Numerics in Excel[edit]

The purpose of this paper is to evaluate the accuracy of MS Excel in terms of statistical procedures and to conclude whether the MS Excel should be used for (statistical) scientific purposes or not. The evaulation is made for Excel versions 97, 2000, XP and 2003.

According to the literature, there are three main problematic areas for Excel if it is used for statistical calculations. These are

  • probability distributions,
  • univariate statistics, ANOVA and Estimations (both linear and non-linear)
  • random number generation.

If the results of statistical packages are assessed, one should take into account that the acceptable accuracy of the results should be achieved in double precision (which means that a result is accepted as accurate if it possesses 15 accurate digits) given that the reliable algorithms are capable of delivering correct results in double precision, as well. If the reliable algorithms can not retrieve results in double precision, it is not fair to anticipate that the package (evaluated) should achieve double precision. Thus we can say that the correct way for evaluating the statistical packages is assessing the quality of underlying algorithm of statistical calculations rather than only counting the accurate digits of results. Besides, test problems must be reasonable which means they must be amenable to solution by known reliable algorithms. (McCullough & Wilson, 1999, S. 28)

In further sections, our judgement about the accuracy of MS Excel will base on certified values and tests. As basis we have Knüsel’s ELV software for probability distributions, StRD (Statistical Reference Datasets) for Univariate Statistics, ANOVA and Estimations and finally Marsaglia’s DIEHARD for Random Number Generation. Each of the tests and certified values will be explained in the corresponding sections.

Assessing Excel Results for Statistical Distributions[edit]

As we mentioned above our judgement about Excel’s calculations for probability distributions will base on Knüsel’s ELV Program which can compute probabilities and quantiles of some elementary statistical distributions. Using ELV, the upper and lower tail probabilities of all distributions are computed with six significant digits for probabilities as small as 10−100 and upper and lower quantiles are computed for all distributions for tail probabilities P with 10−12 ≤ P ≤ ½. (Knüsel, 2003, S.1)

In our benchmark Excel should display no inaccurate digits. If six digits are displayed, then all six digits should be correct. If the algorithm is only accurate to two digits, then only two digits should be displayed so as not to mislead the user (McCullough & Wilson, 2005, S. 1245)

In the following sub-sections the exact values in the tables are retrieved from Knüsel’s ELV software and the acceptable accuracy is in single presicion, because even the best algorithms can not achieve 15 correct digits in most cases, if the probability distributions are issued.

Normal Distribution[edit]

  • Excel Function:NORMDIST
  • Parameters: mean = 0, variance = 1, x (critical value)
  • Computes: the tail probability Pr X ≤ x, whereas X denotes a random variable with a standard normal distribution (with mean 0 and variance 1)
Table 1: (Knüsel, 1998, S.376)

As we can see in table 1, Excel 97, 2000 and XP encounter problems and computes small probabilities in tail incorrectly (i.e for x = -8,3 or x = -8.2) However, this problem is fixed in Excel 2003 (Knüsel, 2005, S.446).

Inverse Normal Distribution[edit]

  • Excel Function: NORMINV
  • Parameters: mean = 0, variance = 1, p (probability for X < x)
  • Computes: the x value (quantile)

X denotes a random variable with a standard normal distribution. In contrast to “NORMDIST” function issued in the last section, p is given and quantile is computed.

If used, Excel 97 prints out quantiles with 10 digits although none of these 10 digits may be correct if p is small. In Excel 2000 and XP, Microsoft tried to fix errors, although results are not sufficient (See table 2). However in Excel 2003 the problem is fixed entirely. (Knüsel, 2005, S.446)

Table 2: (Knüsel, 2002, S.110)

Inverse Chi-Square Distribution[edit]

  • Excel Function: CHIINV
  • Parameters: p (probability for X > x), n (degrees of freedom)
  • Computes: the x value (quantile)

X denotes a random variable with a chi-square distribution with n degrees of freedom.

Table 3: (Knüsel , 1998, S. 376)

Old Excel Versions: Although the old Excel versions show ten significant digits, only very few of them are accurate if p is small (See table 3). Even if p is not small, the accurate digits are not enough to say that Excel is sufficient for this distribution.

Excel 2003: Problem was fixed. (Knüsel, 2005, S.446)

Inverse F Distribution[edit]

  • Excel Function: FINV
  • Parameters: p (probability for X > x), n1, n2 (degrees of freedom)
  • Computes: the x value (quantile)

X denotes a random variable with a F distribution with n1 and n2 degrees of freedom.

Table 4: (Knüsel , 1998, S. 377)

Old Excel Versions: Excel prints out x values with 7 or more significant digits although only one or two of these many digits are correct if p is small (See table 4).

Excel 2003: Problem fixed. (Knüsel, 2005, S.446)

Inverse t Distribution[edit]

  • Excel Function: TINV
  • Parameters: p (probability for |X| > x), n (degree of freedom)
  • Computes: the x value (quantile)

X denotes a random variable with a t distribution with n degrees of freedom. Please note that the |X| value causes a 2 tailed computation. (lower tail & high tail)

Table 5: (Knüsel , 1998, S. 377)

Old Excel Versions: Excel prints out quantiles with 9 or more significant digits although only one or two of these many digits are correct if p is small (See table 5).

Excel 2003: Problem fixed. (Knüsel, 2005, S.446)

Poisson Distribution[edit]

  • Excel Function: Poisson
  • Parameters: λ (mean), k (number of cases)
  • Computes: the tail probability Pr X ≤ k

X denotes a random variable with a Poisson distribution with given parameters.

Table 6: (McCullough & Wilson, 2005, S.1246)

Old Excel Versions: correctly computes very small probabilities but gives no result for central probabilities near the mean (in the range about 0.5). (See table 6)

Excel 2003: The central probabilities are fixed. However, inaccurate results in the tail. (See table 6)

The strange behaivour of Excel can be encountered for values λ150. (Knüsel, 1998, S.375) It fails even for probabilities in the central range between 0.01 and 0.99 and even for parameter values that cannot be judged as too extreme.

Binomial Distribution[edit]

  • Excel Function: BINOMDIST
  • Parameters: n (= number of trials) , υ(= probability for a success) , k(number of successes)
  • Computes: the tail probability Pr X ≤ k

-X denotes a random variable with a binoamial distribution with given parameters

Table 7: (Knüsel, 1998, S.375)

Old Excel Versions: As we see in table 7, old versions of Excel correctly computes very small probabilities but gives no result for central probabilities near the mean (same problem with Poisson distribuiton on old Excel versions)

Excel 2003: The central probabilities are fixed. However, inaccurate results in the tail. (Knüsel, 2005, S.446). (same problem with Poisson distribuiton on Excel 2003).

This strange behaivour of Excel can be encountered for values n > 1000. (Knüsel, 1998, S.375) It fails even for probabilities in the central range between 0.01 and 0.99 and even for parameter values that cannot be judged as too extreme.

Other problems[edit]

  • Excel 97, 2000 and XP includes flaws by computing the hypergeometric distribution (HYPERGEOM). For some values (N > 1030) no result is retrieved. This is prevented on Excel 2003, but there is still no option to compute tail probabilities. So computation of Pr {X = k} is possible, but computation of Pr {X ≤ k} is not. (Knüsel, 2005, S.447)
  • Function GAMMADIST for gamma distribution retreives incorrect values on Excel 2003. (Knüsel, 2005, S.447-448)
  • Also the function BETAINV for inverse beta distribution computes incorrect values on Excel 2003 (Knüsel, 2005, S. 448)

Assessing Excel Results for Univariate Statistics, ANOVA and Estimation (Linear & Non-Linear)[edit]

Our judgement about Excel’s calculations for univariate statistics, ANOVA and Estimation will base on StRD which is designed by Statistical Engineering Division of National Institute of Standards and Technology (NIST) to assist researchers in benchmarking statistical software packages explicitly. StRD has reference datasets (real-world and generated datasets) with certified computational results that enable the objective evaluation of statistical Software. It comprises four suites of numerical benchmarks for statistical software: univariate summary statistics, one way analysis of variance, linear regression and nonlinear regression and it includes several problems for each suite of tests. All problems have a difficulty level:low, average or high.

By assessing Excel results in this section we are going to use LRE (log relative error) which can be used as a score for accuracy of results of statistical packages. The number of correct digits in results can be calculated via log relative error. Please note that for double precision the computed LRE is in the range 0 - 15, because we can have max. 15 correct digits in double precision.

Formula LRE:

\lambda = LRE(x) = -log_{10} \left ( \frac{|x - c|}{|x|} \right )

c: the correct answer (certified computational result) for a particular test problem

x: answer of Excel for the same problem

Univariate Statistics[edit]

  • Excel Functions: - AVERAGE, STDEV, PEARSON (also CORREL)
  • Computes (respectively): mean, standard deviation, correlation coefficient
Table 8: (McCullough & Wilson, 2005, S.1247)

Old Excel Versions: an unstable algorithm for calculation of the sample variance and the correlation coefficient is used. Even for the low difficulty problems (datasets with letter “l” in table 8) the old versions of Excel fail.

Excel 2003: Problem was fixed and the performance is acceptable. The accurate digits less than 15 don’t indicate an unsuccessful implementation because even the reliable algorithms can not retrieve 15 correct digits for these average and high difficulty problems (datasets with letters “a” and “h” in table 8) of StRD.

ONEWAY ANOVA[edit]

  • Excel Function: Tools – Data Analysis – ANOVA: Single Factor (requires Analysis Toolpak)
  • Computes: df, ss, ms, F-statistic

Since ANOVA produces many numerical results (such as df, ss, ms, F), here only the LRE for the final F-statistic is presented. Before assessing Excel’s performance one should consider that a reliable algorithm for one way Analysis of Variance can deliver 8-10 digits for the average difficulty problems and 4-5 digits for higher difficulty problems.

Table 9: (McCullough & Wilson, 2005, S.1248)

Old Excel Versions: Considering numerical solutions, delivering only a few digits of accuracy for difficult problems is not an evidence for bad software, but retrieving 0 accurate digits for average difficulty problems indicates bad software when calculating ANOVA. (McCullough & Wilson, 1999, S. 31). For that reason Excel versions prior than Excel 2003 has an acceptable performance only on low-difficulty problems. It retrieves zero accurate digits for difficult problems. Besides, negative results for “within group sum of squares” and “between group sum of squares” are the further indicators of a bad algorithm used for Excel. (See table 9)

Excel 2003: Problem was fixed (See table 9). The zero digits of accuracy for the Simon 9 test is no cause for concern, since this also occurs when reliable algorithms are employed. Therefore the performance is acceptable. (McCullough & Wilson, 2005, S. 1248)

Linear Regression[edit]

  • Excel Function: LINEST
  • Computes: All numerical results required by Linear Regression

Since LINEST produces many numerical results for linear regression, only the LRE for the coefficients and standard errors of coefficients are taken into account. Table 9 shows the lowest LRE values for each dataset as the weakest link in the chain in order to reflect the worst estimations (smallest \lambda_\beta-LRE and \lambda_\sigma-LRE) made by Excel for each linear regression function.

Old Excel Versions: either doesn't check for near-singularity of the input matrix or checking it incorrectly, so the results for ill-conditioned Dataset “Filip (h)” include not a single correct digit. Actually, Excel should have refused the solution and commit a warning to user about the near singularity of data matrix. (McCullough & Wilson, 1999, S.32,33) . However, in this case, the user is mislead.

Excel 2003: Problem is fixed and Excel 2003 has an acceptable performance. (see table 10)

Table 10: (McCullough & Wilson, 1999, S. 32)

Non-Linear Regression[edit]

When solving nonlinear regression using Excel, it is possible to make choices about:

  1. method of derivative calculation: forward (default) or central numerical derivatives
  2. convergence tolerance (default=1.E-3)
  3. scaling (recentering) the variables
  4. method of solution (default – GRG2 quasi-Newton method)

Excel’s default parameters don’t always produce the best solutions always (like all other solvers). Therefore one needs to give different parameters and test the Excel-Solver for non-linear regression. In table 10 the columns A-B-C-D are combinations of different non-linear options. Because changing the 1st and 4th option doesn’t affect the result, only 2nd and 3rd parameters are changed for testing:

  • A: Default estimation
  • B: Convergence Tolerance = 1E -7
  • C: Automatic Scaling
  • D: Convergence Tolerance = 1E -7 & Automatic Scaling

In Table 11, the lowest LRE principle is applied to simplify the assessment. (like in linear reg.)

Results in table 11 are same for each Excel version (Excel 97, 2000, XP, 2003)

Table 11: (McCullough & Wilson, 1999, S. 34)

As we see in table 11, the non-linear option combination A produces 21 times, B 17 times, C 20 times and D 14 times “0” accurate digits. which indicates that the performance of Excel in this area is inadequate. Expecting to find all exact solutions for all problems with Excel is not fair, but if it is not able to find the result, it is expected to warn user and commit that the solution can not be calculated. Furthermore, one should emphasize that other statistical packages like SPSS, S-PLUS and SAS exhibit zero digit accuracy only few times (0 to 3) in these tests (McCullough & Wilson, 1999, S. 34).

Assessing Random Number Generator of Excel[edit]

Many statistical procedures employ random numbers and it is expected that the generated random numbers are really random. Only random number generators should be used that have solid theoretical properties. Additionally, statistical tests should be applied on samples generated and only generators whose output has successfuly passed a battery of statistical tests should be used. (Gentle, 2003)

Based on the facts explained above we should assess the quality of Random Number Generation by:

  • analysing the underlying algorithm for Random Number Generation.
  • analysing the generators output stream. There are many alternatives to test the output of a RNG. One can evaluate the generated output using static tests in which the generation order is not important. These tests are goodness of fit tests. The second way of evaluating the output stream is running a dynamic test on generator, whereas the generation order of the numbers is important.

Excel’s RNG – Underlying algorithm[edit]

The objective of random number generation is to produce samples any given size that are indistinguishable from samples of the same size from a U(0,1) distribution. (Gentle, 2003) For this purpose there are different algorithms to use. Excel’s algorithm for random number generation is Wichmann–Hill algorithm. Wichmann–Hill is a useful RNG algorithm for common applications, but it is obsolete for modern needs (McCullough & Wilson, 2005, S. 1250). The formula for this random number generator is defined as follows:

X_i  =  171.X_i - 1  mod  30269

Y_i  =  172.Y_i - 1  mod  30307

Z_i  =  170.Z_i - 1  mod  30323

U_i  =  \frac{X_i}{30269} +  \frac{Y_i}{30307} + \frac {Z_i}{30323} mod 1

Wichmann–Hill is a congruential generator which means that it is a recursive aritmethical RNG as we see in the formula above. It is a combination of three other linear congruential generator and requires three seeds: X_0 Y_0 Z_0.

Period, in terms of random number generation, is the number of calls that can be made to the RNG before it begins to repeat. For that reason, having a long period is a quality measure for random number generators. It is essential that the period of the generator be larger than the number of random numbers to be used. Modern applications are increasingly demanding longer and longer sequences of random numbers (i.e for using in Monte-Carlo simulations) (Gentle, 2003)

The lowest acceptable period for a good RNG is 2^{60} and the period of Wichmann-Hill RNG is 6.95E+12 (≈ 2^{43}). In addition to this unacceptable performance, Microsoft claims that the period of Wichmann-Hill RNG is 10E+13 Even if Excel’s RNG has a period of 10E+13, it is still not sufficient to be an acceptable random number generator because this value is also less than 2^{60}. (McCullough & Wilson, 2005, S. 1250)

Furthermore it is known that RNG of Excel produces negative values after the RNG executed many times. However a correct implementation of a Wichmann-Hill Random Number Generator should produce only values between 0 and 1. (McCullough & Wilson, 2005, S. 1249)

Excel’s RNG – The Output Stream[edit]

As we discussed above, it is not sufficient to discuss only the underlying algorithm of a random number generation. One needs also some tests on output stream of a random number generator while assessing the quality of this random number generator. So a Random Number Generator should produce output which passes some tests for randomness. Such a battery of tests, called DIEHARD, has been prepared by Marsaglia. A good RNG should pass almost all of the tests but as we can see in table 12 Excel can pass only 11 of them (7 failure), although Microsoft has declaired Wichmann–Hill Algorithm is implemented for Excel’s RNG. However, we know that Wichmann-Hill is able to pass 16 tests from DIEHARD (McCullough & Wilson, 1999, S. 35).

Due to reasons explained in previous and this section we can say that Excel’s performance is inadequate (because of period length, incorrect implementation Wichmann Hill Algorithm, which is already obsolete, DIEHARD test results)

Table 12: (McCullough & Wilson, 1999, S. 35)

Conclusion[edit]

Old versions of Excel (Excel 97, 2000, XP) :

  • shows poor performance on following distributions: Normal, F, t, Chi Square, Binomial, Poisson, Hypergeometric
  • retrieves inadequate results on following calculations: Univariate statistics, ANOVA, linear regression, non-linear regression
  • has an unacceptable random number generator

For those reasons, we can say that use of Excel 97, 2000, XP for (statistical) scientific purposes should be avoided.

Although several bugs are fixed in Excel 2003, still use of Excel for (statistical) scientific purposes should be avoided because it:

  • has a poor performance on following distributions: Binomial, Poisson, Gamma, Beta
  • retrieves inadequate results for non-linear regression
  • has an obsolete random number generator.

References[edit]

  • Gentle J.E. (2003) Random number generation and Monte Carlo methods 2nd edition. New York Springer Verlag
  • Knüsel, L. (2003) Computation of Statistical Distributions Documentation of the Program ELV Second Edition. http://www.stat.uni-muenchen.de/~knuesel/elv/elv_docu.pdf Retrieved [13 November 2005]
  • Knüsel, L. (1998). On the Accuracy of the Statistical Distributions in Microsoft Excel 97. Computational Statistics and Data Analysis (CSDA), Vol. 26, 375-377.
  • Knüsel, L. (2002). On the Reliability of Microsoft Excel XP for statistical purposes. Computational Statistics and Data Analysis (CSDA), Vol. 39, 109-110.
  • Knüsel, L. (2005). On the Accuracy of Statistical Distributions in Microsoft Excel 2003. Computational Statistics and Data Analysis (CSDA), Vol. 48, 445-449.
  • McCullough, B.D. & Wilson B. (2005). On the accuracy of statistical procedures in Microsoft Excel 2003. Computational Statistics & Data Analysis (CSDA), Vol. 49, 1244 – 1252.
  • McCullough, B.D. & Wilson B. (1999). On the accuracy of statistical procedures in Microsoft Excel 97. Computational Statistics & Data Analysis (CSDA), Vol. 31, 27– 37.
  • PC Magazin, April 6, 2004, p.71*

Distributions Problems[edit]

A normal distribution has μ = 100 and σ = 15. What percent of the distribution is greater than 120?

Authors[edit]

Authors and contributors to this book include:


Glossary[edit]

This is a glossary of the book.

Contents: Top - 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

P[edit]

primary data 
Original data that have been collected specially for the purpose in mind.
population 
Entire group being considered for data collection, that we want to draw conclusions about. EX: The population of the United States

R[edit]

Random variable
A function that associates a specific and unique numerical value with each outcome of an experiment. (EX: X or Y) The outcome is denoted as lower case

S[edit]

sample 
a group of units taken from a larger group (the population). Used to draw conclusions of the larger group. EX: 30 people in a town in the US.
secondary data 
Data that have been collected for another purpose and where we will use Statistical Method with the Primary Data.
statistic 
A measure that is calculated from a sample of data.
Statistical Independence 
They do not affect each other

Z[edit]