Skip to content

Commit fd78f1f

Browse files
DOC: random: Copy-edit zipf docstring: zipf is a discrete distribution.
1 parent f0cce63 commit fd78f1f

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

numpy/random/_generator.pyx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3107,7 +3107,7 @@ cdef class Generator:
31073107
`a` > 1.
31083108
31093109
The Zipf distribution (also known as the zeta distribution) is a
3110-
continuous probability distribution that satisfies Zipf's law: the
3110+
discrete probability distribution that satisfies Zipf's law: the
31113111
frequency of an item is inversely proportional to its rank in a
31123112
frequency table.
31133113
@@ -3135,9 +3135,10 @@ cdef class Generator:
31353135
-----
31363136
The probability density for the Zipf distribution is
31373137
3138-
.. math:: p(x) = \\frac{x^{-a}}{\\zeta(a)},
3138+
.. math:: p(k) = \\frac{k^{-a}}{\\zeta(a)},
31393139
3140-
where :math:`\\zeta` is the Riemann Zeta function.
3140+
for integers ``k`` >= 1, where :math:`\\zeta` is the Riemann Zeta
3141+
function.
31413142
31423143
It is named for the American linguist George Kingsley Zipf, who noted
31433144
that the frequency of any word in a sample of a language is inversely
@@ -3167,10 +3168,10 @@ cdef class Generator:
31673168
`bincount` provides a fast histogram for small integers.
31683169
31693170
>>> count = np.bincount(s)
3170-
>>> x = np.arange(1, s.max() + 1)
3171+
>>> k = np.arange(1, s.max() + 1)
31713172
3172-
>>> plt.bar(x, count[1:], alpha=0.5, label='sample count')
3173-
>>> plt.plot(x, n*(x**-a)/zeta(a), 'k.-', alpha=0.5,
3173+
>>> plt.bar(k, count[1:], alpha=0.5, label='sample count')
3174+
>>> plt.plot(k, n*(k**-a)/zeta(a), 'k.-', alpha=0.5,
31743175
... label='expected count') # doctest: +SKIP
31753176
>>> plt.semilogy()
31763177
>>> plt.grid(alpha=0.4)

numpy/random/mtrand.pyx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3609,7 +3609,7 @@ cdef class RandomState:
36093609
`a` > 1.
36103610
36113611
The Zipf distribution (also known as the zeta distribution) is a
3612-
continuous probability distribution that satisfies Zipf's law: the
3612+
discrete probability distribution that satisfies Zipf's law: the
36133613
frequency of an item is inversely proportional to its rank in a
36143614
frequency table.
36153615
@@ -3642,9 +3642,10 @@ cdef class RandomState:
36423642
-----
36433643
The probability density for the Zipf distribution is
36443644
3645-
.. math:: p(x) = \\frac{x^{-a}}{\\zeta(a)},
3645+
.. math:: p(k) = \\frac{k^{-a}}{\\zeta(a)},
36463646
3647-
where :math:`\\zeta` is the Riemann Zeta function.
3647+
for integers ``k`` >= 1, where :math:`\\zeta` is the Riemann Zeta
3648+
function.
36483649
36493650
It is named for the American linguist George Kingsley Zipf, who noted
36503651
that the frequency of any word in a sample of a language is inversely
@@ -3674,10 +3675,10 @@ cdef class RandomState:
36743675
`bincount` provides a fast histogram for small integers.
36753676
36763677
>>> count = np.bincount(s)
3677-
>>> x = np.arange(1, s.max() + 1)
3678+
>>> k = np.arange(1, s.max() + 1)
36783679
3679-
>>> plt.bar(x, count[1:], alpha=0.5, label='sample count')
3680-
>>> plt.plot(x, n*(x**-a)/zeta(a), 'k.-', alpha=0.5,
3680+
>>> plt.bar(k, count[1:], alpha=0.5, label='sample count')
3681+
>>> plt.plot(k, n*(k**-a)/zeta(a), 'k.-', alpha=0.5,
36813682
... label='expected count') # doctest: +SKIP
36823683
>>> plt.semilogy()
36833684
>>> plt.grid(alpha=0.4)

0 commit comments

Comments
 (0)