def zipf_cdf(k, s, N): """ Gives the value of the Zipf cumulative distribution function for the given k (k can be a whole, in [1, 2, ..., N]) and the specified parameters of the Zipf distribution- s >= 0, N in [1, 2, ...] """ A = functions.generalized_harmonic_number_function(k, s) B = functions.generalized_harmonic_number_function(N, s) return A/B
def zipf_pmf(k, s, N): """ Gives the value of the Zipf probability mass function for the given k (k can be a whole, in [1, 2, ..., N]) and the specified parameters of the Zipf distribution- s >= 0, N in [1, 2, ...] """ A = 1/math.pow(k, s) B = functions.generalized_harmonic_number_function(N, s) return A/B
def __init__(self, s, N): """ Sets the parameters for the Zipf distribution. s must be > 0. """ if s < 0: raise IncorrectDistributionInicializationError() self.s = s self.N = N A = functions.generalized_harmonic_number_function(N, s-1) B = functions.generalized_harmonic_number_function(N, s) self.mean = A/B # http://mathworld.wolfram.com/ZipfDistribution.html # http://mathworld.wolfram.com/RiemannZetaFunction.html # - bad integral # self.variance = "Implement me!" self.mode = 1