Verified Commit 1a30f390 authored by Renato Alves's avatar Renato Alves 🌱
Browse files

Include density cumulative function

parent 9b5a6eef
......@@ -600,7 +600,7 @@ plt.title(f"Normal distribution - mean={mean}, stdev={stdev}, samples={samples},
> to have a nicely typeset `μ` character in the title.
> Doing full stylization with LaTeX we could use:
> ~~~
> plt.title(f"$X \\sim \\mathcal{N}(\\mu,\\,\\sigma^{2})$ - $\\mu$={mean}, $\\sigma^{2}$={stdev}, samples={samples}, binning={1/bins}")
> plt.title(f"$X \\sim \\mathcal{{N}}(\\mu,\\,\\sigma^{{2}})$ - $\\mu$={mean}, $\\sigma^{{2}}$={stdev}, samples={samples}, binning={1/bins}")
> ~~~
> {: .language-python }
>
......@@ -615,10 +615,42 @@ plt.title(f"Normal distribution - mean={mean}, stdev={stdev}, samples={samples},
> by prefixing it with `r`, becoming `r"\alpha"`.
{: .callout }
## Scatter
> ## A Dense Histogram
>
> Exploring the [documentation of `plt.hist()`][matplotlib-hist], find how to add
> a *probability density* projection of the plot above.
>
> When plotting as density, the values in the `Y` axis change.
> Is this representation easier to understand than the default histogram with counts?
> What if in addition the histogram is made cumulative?
>
> > ## Solution
> >
> > The `plt.hist()` function accepts a `density=True` and a `cumulative=True` option.
> > Although the `Y` axis values change, the bars should have the same visual representation
> > (unless a new random sample was generated).
> >
> > A density plot transforms the `Y` scale such that the area under the histogram
> > adds to `1`.
> > A value of `0.40` implies that the area occupied by the central bar represents 40% of the points.
> > ~~~
> > plt.hist(normal_dist, bins, density=True)
> > ~~~
> > {: .language-python }
> > ![Histogram as density](../fig/normal-hist-density.png)
> >
> > A perhaps more intuitive plot, is represented by the cumulative density, which
> > as previously described should add to `1`.
> > ~~~
> > plt.hist(normal_dist, bins, density=True, cumulative=True)
> > ~~~
> > {: .language-python }
> > ![Histogram as cumulative density](../fig/normal-hist-cumuldensity.png)
> >
> {: .solution }
{: .challenge }
## Bar
## Histograms
## Subplots
- the next exercise assumes an example of subplots arranged in a single row or column
......
fig/normal-hist-latex.png

37.1 KB | W: | H:

fig/normal-hist-latex.png

36.1 KB | W: | H:

fig/normal-hist-latex.png
fig/normal-hist-latex.png
fig/normal-hist-latex.png
fig/normal-hist-latex.png
  • 2-up
  • Swipe
  • Onion skin
fig/normal-hist.png

40 KB | W: | H:

fig/normal-hist.png

39 KB | W: | H:

fig/normal-hist.png
fig/normal-hist.png
fig/normal-hist.png
fig/normal-hist.png
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment