Skip to content

Modern Math NextExponential

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Math Library › Math Library › NextExponential

NextExponential

Returns a random waiting time between events at rate lambda; its mean is 1/lambda.

Syntax

NextExponential( lambda )

Examples

#import "std/numeric"
using numeric

dim r as Rng = RngFromEntropy( )

'' The waiting time between events arriving at rate lambda. Its mean is
'' 1/lambda, so a bigger lambda gives shorter gaps.
dim as float64 total = 0
for i as int32 = 1 to 2000
    total += r.NextExponential( 2.0 )
next
dim as float64 mean_ = total / 2000

print mean_ > 0.35 andalso mean_ < 0.65   '' -1 (true), around 0.5

Library: Math Library
Category: Math Library
Documented under: Nothing Becomes A Keyword

Clone this wiki locally