# Histogram Command

From GeoGebra Manual

- Histogram( <List of Class Boundaries>, <List of Heights> )
- Creates a histogram with bars of the given heights. The class boundaries determine the width and position of each bar of the histogram.

**Example:**

`Histogram({0, 1, 2, 3, 4, 5}, {2, 6, 8, 3, 1})`

creates a histogram with 5 bars of the given heights. The first bar is positioned at the interval [*0, 1*], the second bar is positioned at the interval [

*1, 2*], and so on.

- Histogram( <List of Class Boundaries>, <List of Raw Data>, <Boolean Use Density>, <Density Scale Factor>(optional) )
- Creates a histogram using the raw data. The class boundaries determine the width and position of each bar of the histogram and are used to determine how many data elements lie in each class. Bar height is determined as follows

- If
*Use Density = true*, height = (Density Scale Factor) * (class frequency) / (class width) - If
*Use Density = false*, height = class frequency

- If

- By default, Use Density = true and Density Scale Factor = 1. This creates a histogram with total area = n, the number of data values.

**Note:**All elements of Raw Data must be within the interval of the class boundaries, otherwise “undefined” will be returned.

**Note:**By convention this uses the a ≤ x < b rule for each class except for the last class which is a ≤ x ≤ b

**Example:**(

*Default Histogram*)

`Histogram({10, 20, 30, 40}, {10, 11, 11, 12, 18, 20, 25, 40}, true)`

creates a histogram with 3 bars, with the heights 0.5 (first bar), 0.2 (second bar), and 0.1 (third bar).- This histogram has total area = 0.5*10 + 0.2*10 + 0.1*10 = 8.

**Example:**(

*Count Histogram*)

`Histogram({10, 20, 30, 40}, {10, 11, 11, 12, 18, 20, 25, 40}, false)`

creates a histogram with 3 bars, with the heights 5 (first bar), 2 (second bar), and 1 (third bar). This histogram does not use density scaling and gives bar heights that equal the count of values in each class.

**Example:**(

*Relative Frequency Histogram*)

`Histogram({10, 20, 30, 40}, {10, 11, 11, 12, 18, 20, 25, 40}, true, 10/ 8)`

creates a histogram with 3 bars, with the heights 0.625 (first bar), 0.25 (second bar), and 0.125 (third bar). This histogram uses density scaling to give bar heights that equal the proportion of values in each class.- If n is the number of data values, and the classes have constant width w, then Density Scale Factor = w/n creates a relative histogram.

**Example:**(

*Normalized Histogram*)

`Histogram({10, 20, 30, 40}, {10, 11, 11, 12, 18, 20, 25, 40}, true, 1/8)`

creates a histogram with 3 bars, with the heights .0625 (first bar), .025 (second bar), and .0125 (third bar).- This histogram has total area = .0625*10 + .025*10 + .0125*10 = 1.
- If n is the number of data values, then Density Scale Factor = 1/n creates a normalized histogram with total area = 1. This is useful for fitting a histogram with a density curve.

- Histogram( <Boolean Cumulative>, <List of Class Boundaries>, <List of Raw Data>, <Boolean Use Density> , <Density Scale Factor> (optional) )
- If Cumulative is true this creates a histogram where each bar height equals the frequency of the class plus the sum of all previous frequencies.

**Example:**:

`Histogram(true, {10, 20, 30, 40}, {10, 11, 11, 12, 18, 20, 25, 40}, true)`

creates a histogram with 3 bars, with the heights 0.5 (first bar), 0.7 (second bar), and 0.8 (third bar).