|
98 | 98 | # and (``np.sum(density * np.diff(bins)) == 1``).
|
99 | 99 | #
|
100 | 100 | # This normalization is how `probability density functions
|
101 |
| -# <https://en.wikipedia.org/wiki/Probability_density_function>`_ are |
102 |
| -# defined in statistics. If :math:`X` is a random variable on :math:`x`, then |
103 |
| -# :math:`f_X` is is the probability density function if :math:`P[a<X<b] = |
104 |
| -# \int_a^b f_X dx`. Note that if the units of x are Volts (for instance), then |
105 |
| -# the units of :math:`f_X` are :math:`V^{-1}` or probability per change in |
106 |
| -# voltage. |
| 101 | +# <https://en.wikipedia.org/wiki/Probability_density_function>`_ are defined in |
| 102 | +# statistics. If :math:`X` is a random variable on :math:`x`, then :math:`f_X` |
| 103 | +# is is the probability density function if :math:`P[a<X<b] = \int_a^b f_X dx`. |
| 104 | +# If the units of x are Volts, then the units of :math:`f_X` are :math:`V^{-1}` |
| 105 | +# or probability per change in voltage. |
107 | 106 | #
|
108 | 107 | # The usefulness of this normalization is a little more clear when we draw from
|
109 | 108 | # a known distribution and try to compare with theory. So, choose 1000 points
|
|
159 | 158 | ax['True'].legend(fontsize='small')
|
160 | 159 |
|
161 | 160 | # %%
|
| 161 | + |
162 | 162 | # Sometimes people want to normalize so that the sum of counts is one. This is
|
163 |
| -# _not_ done with the *density* kwarg, but instead we can set the *weights* to |
164 |
| -# 1/N. Note, however, that the amplitude of the histogram still depends on |
165 |
| -# width of the bins |
| 163 | +# not done with the *density* kwarg, but rather we can get this effects if we |
| 164 | +# set the *weights* to 1/N. Note, however, that the amplitude of the histogram |
| 165 | +# still depends on width of the bins: |
166 | 166 |
|
167 | 167 | fig, ax = plt.subplots(layout='constrained', figsize=(3.5, 3))
|
168 | 168 |
|
|
176 | 176 |
|
177 | 177 | # %%
|
178 | 178 | # The true value of normalizing is if you do want to compare two distributions
|
179 |
| -# that have different sized populations: |
| 179 | +# that have different sized populations. Here we compare the distribution of |
| 180 | +# ``xdata`` with a population of 1000, and ``xdata2`` with 100 members. |
180 | 181 |
|
181 | 182 | xdata2 = rng.normal(size=100)
|
182 | 183 |
|
|
0 commit comments