# Histograms

In this lesson, learn how to visualize and interpret a dataset using a histogram.

Start## Key Concepts

Review core concepts you need to learn to master this subject

Mean of a Dataset

Histogram Bins

Histogram Bin Count

Histogram’s X and Y Axis

Matplotlib Function To Create Histogram

What is a Histogram?

Mean of a Dataset

Mean of a Dataset

The *mean*, or average, of a dataset is calculated by adding all the values in the dataset and then dividing by the number of values in the set.

For example, for the dataset `[1,2,3]`

, the mean is `1+2+3`

/ `3`

= `2`

.

Histogram Bins

Histogram Bins

In a histogram, the range of the data is divided into sub-ranges represented by *bins*. The width of the bin is calculated by dividing the range of the dataset by the number of bins, giving each bin in a histogram the same width.

Histogram Bin Count

Histogram Bin Count

In a histogram, the bin *count* is the number of data points that fall within the bin’s range.

Histogram’s X and Y Axis

Histogram’s X and Y Axis

A histogram is a graphical representation of the distribution of numerical data. In a histogram, the bin ranges are on the x-axis and the counts are on the y-axis.

Matplotlib Function To Create Histogram

Matplotlib Function To Create Histogram

In Python, the `pyplot.hist()`

function in the Matplotlib pyplot library can be used to plot a histogram. The function accepts a NumPy array, the range of the dataset, and the number of bins as input.

What is a Histogram?

What is a Histogram?

A *Histogram* is a plot that displays the spread, or distribution of a dataset. In a histogram, the data is split into intervals, called bins. Each bin shows the number of data points that are contained within that bin.

- 1Statistics is often pitched as a way to find certainty through data. As you’ll learn in this lesson, the power of statistics is more often used to communicate that certainty doesn’t really exist. I…
- 2The purpose of a histogram is to summarize data that you can use to inform a decision or explain a distribution. While a histogram is one of the most useful tools for communicating trends, people …
- 3Histograms are helpful for understanding how your data is distributed. While the average time a customer may arrive at the grocery store is 3 pm, the manager knows 3 pm is not the busiest time of d…
- 4In the previous exercise, you found that the earliest transaction time is close to 0, and the latest transaction is close to 24, making your range nearly 24 hours. Now, we have the information we …
- 5A
*count*is the number of values that fall within a bin’s range. For example, if 100 customers arrive at your grocery store between midnight (0) and 6 am (6), your count for that bin is equal to 1… - 6While counting the number of values in a bin is straightforward, it is also time-consuming. How long do you think it would take you to count the number of values in each bin for: - an exercise clas…
- 7At this point, you’ve learned how to find the numerical inputs to a histogram. Thus far the size of our datasets and bins have produced results that we can interpret. This becomes increasingly diff…
- 8The figure below displays the graph that you created in the last exercise: This histogram is helpful for our store manager. The last six hours of the day are the busiest — from 6 pm until…
- 9In this lesson, you learned what a histogram is, how to calculate it using NumPy, and how to plot one with Matplotlib. The example that we used throughout this lesson, finding the busiest times of…

## What you'll create

Portfolio projects that showcase your new skills

## How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory