UNPKG

@stdlib/random-iter-lognormal

Version:

Create an iterator for generating pseudorandom numbers drawn from a lognormal distribution.

122 lines (103 loc) 2.52 kB
/* * @license Apache-2.0 * * Copyright (c) 2019 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // TypeScript Version: 4.1 /// <reference types="@stdlib/types"/> import * as random from '@stdlib/types/random'; import { TypedIterator } from '@stdlib/types/iter'; /** * Interface defining function options. */ interface Options { /** * Pseudorandom number generator which generates uniformly distributed pseudorandom numbers. */ prng?: random.PRNG; /** * Pseudorandom number generator seed. */ seed?: random.PRNGSeedMT19937; /** * Pseudorandom number generator state. */ state?: random.PRNGStateMT19937; /** * Specifies whether to copy a provided pseudorandom number generator state (default: `true`). */ copy?: boolean; /** * Number of iterations. */ iter?: number; } /** * Interface for iterators of pseudorandom numbers drawn from a lognormal distribution. */ interface Iterator<T> extends TypedIterator<T> { /** * Underlying PRNG. */ readonly PRNG: random.PRNG; /** * PRNG seed. */ readonly seed: random.PRNGSeedMT19937; /** * PRNG seed length. */ readonly seedLength: number; /** * PRNG state. */ state: random.PRNGStateMT19937; /** * PRNG state length. */ readonly stateLength: number; /** * PRNG state size (in bytes). */ readonly byteLength: number; } /** * Returns an iterator for generating pseudorandom numbers drawn from a lognormal distribution. * * @param mu - location parameter * @param sigma - scale parameter * @param options - function options * @throws `sigma` must be a positive number * @throws must provide valid options * @throws must provide a valid state * @returns iterator * * @example * var iter = iterator( -1.0, 3.0 ); * * var r = iter.next().value; * // returns <number> * * r = iter.next().value; * // returns <number> * * r = iter.next().value; * // returns <number> * * // ... */ declare function iterator( mu: number, sigma: number, options?: Options ): Iterator<number>; // EXPORTS // export = iterator;