Skip to content

Latest commit

 

History

History
64 lines (42 loc) · 1.11 KB

zipf.md

File metadata and controls

64 lines (42 loc) · 1.11 KB

zipf

Draw samples from a Zipf distribution.

API

Numeric.random.zipf(first, count, generator)

Produces rank weighted variates from the given exponent.

  • Parameters:
    • first: Exponent parameter of the distribution
    • count: Number of samples to draw when given
    • generator: Generator supplying uniform samples
  • Returns: Single sample or array of samples
  • NumPy: Equivalent to Generator.zipf.

Examples

Draw three samples

import Numeric from '@neabyte/numerix'

const values = Numeric.random.zipf(2, 3, Numeric.random.seed(42))

console.log(values)
// [1,1,8]

Draw a single sample

import Numeric from '@neabyte/numerix'

const value = Numeric.random.zipf(2, undefined, Numeric.random.seed(42))

console.log(value)
// 1

Draw samples with a larger exponent

import Numeric from '@neabyte/numerix'

const values = Numeric.random.zipf(3, 3, Numeric.random.seed(42))

console.log(values)
// [1,1,2]

Draw samples without a generator

import Numeric from '@neabyte/numerix'

const values = Numeric.random.zipf(2, 3)

console.log(values.length)
// 3