bundles / scipy latest / scipy / stats / _continuous_distns / reciprocal_gen
class
scipy.stats._continuous_distns:reciprocal_gen
Signature
class reciprocal_gen ( momtype = 1 , a = None , b = None , xtol = 1e-14 , badvalue = None , name = None , longname = None , shapes = None , seed = None ) Members
Summary
A loguniform or reciprocal continuous random variable.
Extended Summary
%(before_notes)s
Notes
The probability density function for this class is:
for , . This class takes and as shape parameters.
%(after_notes)s
%(example)s
This doesn't show the equal probability of 0.01, 0.1 and 1. This is best when the x-axis is log-scaled:
>>> import numpy as np >>> import matplotlib.pyplot as plt >>> fig, ax = plt.subplots(1, 1) >>> ax.hist(np.log10(r)) >>> ax.set_ylabel("Frequency") >>> ax.set_xlabel("Value of random variable") >>> ax.xaxis.set_major_locator(plt.FixedLocator([-2, -1, 0])) >>> ticks = ["$10^{{ {} }}$".format(i) for i in [-2, -1, 0]] >>> ax.set_xticklabels(ticks) # doctest: +SKIP >>> plt.show()
This random variable will be log-uniform regardless of the base chosen for a and b. Let's specify with base 2 instead:
>>> rvs = %(name)s(2**-2, 2**0).rvs(size=1000)Values of 1/4, 1/2 and 1 are equally likely with this random variable. Here's the histogram:
>>> fig, ax = plt.subplots(1, 1) >>> ax.hist(np.log2(rvs)) >>> ax.set_ylabel("Frequency") >>> ax.set_xlabel("Value of random variable") >>> ax.xaxis.set_major_locator(plt.FixedLocator([-2, -1, 0])) >>> ticks = ["$2^{{ {} }}$".format(i) for i in [-2, -1, 0]] >>> ax.set_xticklabels(ticks) # doctest: +SKIP >>> plt.show()
Aliases
-
scipy.stats._continuous_distns.reciprocal_gen