maths.freeStatistics & Probability › Describing data › Histogram

Histogram

A histogram is a visual representation of the distribution of quantitative data.

Histogram

A histogram is a visual representation of the distribution of quantitative data. To construct a histogram, the first step is to "bin" (or "bucket") the range of values, divide the entire range of values into a series of intervals, and then count how many values fall into each interval. The bins are usually specified as consecutive, non-overlapping intervals of a variable. The bins (intervals) are adjacent and are typically (but not required to be) of equal size.

Histograms give a rough sense of the density of the underlying distribution of the data, and often for density estimation: estimating the probability density function of the underlying variable. The total area of a histogram used for probability density is always normalized to 1. If the length of the intervals on the x-axis are all 1, then a histogram is identical to a relative frequency plot.

Histograms are sometimes confused with bar charts. In a histogram, each bin is for a different range of values, so altogether the histogram illustrates the distribution of values. But in a bar chart, each bar is for a different category of observations (e.g., each bar might be for a different population), so altogether the bar chart can be used to compare different categories. Some authors recommend that bar charts always have gaps between the bars to clarify that they are not histograms.

Etymology

The term histogram was first introduced by Karl Pearson, the founder of mathematical statistics, in lectures delivered in 1892 at University College London. Pearson's term is sometimes incorrectly said to combine the Greek root γραμμα (gramma; 'figure' or 'drawing') with the root ἱστορία (historia; 'inquiry or 'history'). Alternatively the root ἱστίον (histion) is also proposed, meaning 'web' or 'tissue' (as in histology, the study of biological tissue). Both of these etymologies are incorrect, and in fact Pearson, who knew Ancient Greek well, derived the term from a different if homophonous Greek root, ἱστός ('something set upright' or 'mast'), referring to the vertical bars in the graph. Pearson's new term was embedded in a series of other analogous neologisms, such as stigmogram and radiogram.

Pearson himself noted in 1895 that, although the term histogram was new, the type of graph it designates was "a common form of graphical representation". In fact the technique of using a bar graph to represent statistical measurements was devised by the Scottish economist, William Playfair, in his Commercial and political atlas (1786).

Examples

This is the data for the histogram to the right, using 500 items:

The words used to describe the patterns in a histogram are: "symmetric", "skewed left" or "right", "unimodal", "bimodal" or "multimodal".

It is a good idea to plot the data using several different bin widths to learn more about it. Here is an example on tips given in a restaurant.

The U.S. Census Bureau found that there were 124 million people who work outside of their homes. Using their data on the time occupied by travel to work, the table below shows the absolute number of people who responded with travel times "at least 30 but less than 35 minutes" is higher than the numbers for the categories above and below it. This is likely due to people rounding their reported journey time. The problem of reporting values as somewhat arbitrarily rounded numbers is a common phenomenon when collecting data from people.

This histogram shows the number of cases per unit interval as the height of each block, so that the area of each block is equal to the number of people in the survey who fall into its category. The area under the curve represents the total number of cases (124 million). This type of histogram shows absolute numbers, with Q in thousands.

This histogram differs from the first only in the vertical scale. The area of each block is the fraction of the total that each category represents, and the total area of all the bars is equal to 1 (the fraction meaning "all"). The curve displayed is a simple density estimate. This version shows proportions, and is also known as a unit area histogram.

In other words, a histogram represents a frequency distribution by means of rectangles whose widths represent class intervals and whose areas are proportional to the corresponding frequencies: the height of each is the average frequency density for the interval. The intervals are placed together in order to show that the data represented by the histogram, while exclusive, is also contiguous. (E.g., in a histogram it is possible to have two connecting intervals of 10.5-20.5 and 20.5-33.5, but not two connecting intervals of 10.5-20.5 and 22.5-32.5. Empty intervals are represented as empty and not skipped.)

Mathematical definitions

The data used to construct a histogram are generated via a function mi that counts the number of observations that fall into each of the disjoint categories (known as bins). Thus, if we let n be the total number of observations and k be the total number of bins, the histogram data mi meet the following conditions:

\(n = \sum_{i=1}^k{m_i}.\)

A histogram can be thought of as a simplistic kernel density estimation, which uses a kernel to smooth frequencies over the bins. This yields a smoother probability density function, which will in general more accurately reflect distribution of the underlying variable. The density estimate could be plotted as an alternative to the histogram, and is usually drawn as a curve rather than a set of boxes. Histograms are nevertheless preferred in applications, when their statistical properties need to be modeled. The correlated variation of a kernel density estimate is very difficult to describe mathematically, while it is simple for a histogram where each bin varies independently.

An alternative to kernel density estimation is the average shifted histogram, which is fast to compute and gives a smooth curve estimate of the density without using kernels.

Cumulative histogram

A cumulative histogram: a mapping that counts the cumulative number of observations in all of the bins up to the specified bin. That is, the cumulative histogram Mi of a histogram mj can be defined as:

\(M_i = \sum_{j=1}^i{m_j}.\)

Number of bins and width

There is no "best" number of bins, and different bin sizes can reveal different features of the data. Grouping data is at least as old as Graunt's work in the 17th century, but no systematic guidelines were given until Sturges's work in 1926.

Using wider bins where the density of the underlying data points is low reduces noise due to sampling randomness; using narrower bins where the density is high (so the signal drowns the noise) gives greater precision to the density estimation. Thus varying the bin-width within a histogram can be beneficial. Nonetheless, equal-width bins are widely used.

Some theoreticians have attempted to determine an optimal number of bins, but these methods generally make strong assumptions about the shape of the distribution. Depending on the actual data distribution and the goals of the analysis, different bin widths may be appropriate, so experimentation is usually needed to determine an appropriate width. There are, however, various useful guidelines and rules of thumb.

The number of bins k can be assigned directly or can be calculated from a suggested bin width h as:

\(k = \left \lceil \frac{\max x - \min x}{h} \right \rceil.\)

The braces indicate the ceiling function.

Applications

  • In hydrology the histogram and estimated density function of rainfall and river discharge data, analysed with a probability distribution, are used to gain insight in their behaviour and frequency of occurrence. An example is shown in the blue figure.
  • In many Digital image processing programs there is an histogram tool, which show you the distribution of the contrast / brightness of the pixels.

ngoku Akukho calculator icwangcisa le nto, kodwa iinxalenye zayo zibalaseleyo. Zama enye ezantsi, okanye ubhale yakho.

Ukugcina umsebenzi wakho

I akhawunti ekhululekileyo idibanisa amaphetshana kwi ncwadi nganye, irekhodi lento ogqibe ngayo, iingxaki zakho ezisoliweyo kwindawo enye, nomfundi onokuthi ubuze malunga nale phepha. IiMathematiki ngokwazo zivuliwe kubo bonke, bangeniswe okanye hayi.

Bhalisa Igama elithile

Iimpawu ezisetyenziswa apha

Nqakraza nasiphi na isibonakaliso sokuqonda okupheleleyo, umfanekiso, nokuba iileta zonke zithetha ntoni.

Imibuzo abantu bebuza

Mean or median, which should I use?

Median when the data have outliers or a long tail (incomes, house prices); mean when the data are roughly symmetric and you want every value to count. Report both if they disagree. The gap is itself information.

What does a p-value actually say?

The probability of seeing data at least this extreme if the null hypothesis were true. It is not the probability that the null hypothesis is true.

Why divide by n − 1 for the sample variance?

The sample mean sits closer to the sample than the true mean does, so squared deviations from it are slightly too small on average; dividing by n − 1 instead of n corrects the bias.

Iindawo zephepha zitshintshiwe Wikipedia (CC BY-SA 4.0). Igqityiwe kwaye iphinde yacaciswa apha; iimpazamo zethu.

IiNkqubo Statistics & Probability