RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • binornd
    • bootstrp
    • datasample
    • dividerand
    • exprnd
    • gamrnd
    • lhsdesign
    • mvnrnd
    • normrnd
    • random
    • randsample
    • rng
    • trnd
    • unidrnd
    • unifrnd
    • wblrnd

exprnd — Generate exponentially distributed random samples with mean mu and MATLAB-compatible size handling.

exprnd(mu, ...) draws exponential random samples using mean parameter mu. It supports MATLAB-compatible scalar expansion and explicit output-size signatures.

Syntax

r = exprnd(mu)
r = exprnd(mu, sz)
r = exprnd(mu, sz1, sz2, ...)

Inputs

NameTypeRequiredDefaultDescription
muAnyYes—Exponential mean parameter (must be > 0).
szAnyYes—Size scalar or size vector argument.
szAnyVariadic—Dimension extents for output shape.

Returns

NameTypeDescription
rNumericArrayRandom sample array from exponential distribution.

Errors

IdentifierWhenMessage
RunMat:exprnd:MuMustBePositivemu is zero or negative.exprnd: mu must be greater than zero
RunMat:exprnd:InvalidArgumentInput parameters or size arguments are missing or malformed.exprnd: invalid argument
RunMat:exprnd:InternalInternal conversion/allocation/provider decode fails.exprnd: internal operation failed

How exprnd works

  • exprnd(mu) returns one sample per element of mu and preserves the shape and single/double precision of mu.
  • exprnd(mu, n) returns an n × n matrix of samples.
  • exprnd(mu, m, n) returns an m × n matrix of samples.
  • exprnd(mu, sz) accepts a size vector and returns an array with shape sz.
  • A scalar mu expands to an explicitly requested output shape; a nonscalar mu requires that shape to match exactly.
  • Zero or negative size extents produce an empty array, and trailing singleton dimensions beyond dimension two are ignored.
  • mu must contain finite positive values; logical and complex means reject.
  • MATLAB documents mu and size controls as single or double. RunMat can additionally accept typed-integer means and sizes only when RunMat extensions are enabled.
  • Resident fallback returns output only to the exact mean input owner and only when that owner physically supports the required precision; otherwise the correctly typed output remains on the host. Native array-mean/single provider hooks and independent CPU/GPU random streams remain provider-ABI work.

Examples

Single sample from Exp(2)

rng(0);
r = exprnd(2)

Matrix of arrival times for a Poisson process (lambda = 2)

rng(0);
lambda = 2;
intervals = exprnd(1/lambda, 1, 5)

M/M/1 queueing simulation fragment

rng(0);
lambda = 2; mu_svc = 2.5; Tsim = 100;
t = 0; arrivals = 0;
while t < Tsim
    t = t + exprnd(1/lambda);
    arrivals = arrivals + 1;
end
arrivals

Specifying dimensions with a size vector

rng(0);
T = exprnd(1, [2 3])

Using exprnd with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how exprnd changes the result.

Run a small exprnd example, explain the result, then change one input and compare the output.

FAQ

What is the relationship between mu and lambda?⌄

The exponential distribution can be parameterised by its mean mu or its rate lambda. They are reciprocals: mu = 1/lambda. exprnd(mu) is equivalent to exprnd(1/lambda).

What is the workaround if exprnd is unavailable?⌄

exprnd(mu) is mathematically equivalent to -mu * log(rand()). You can substitute -log(rand())/lambda inline until exprnd is available.

Why must mu be positive?⌄

A non-positive mean is undefined for the exponential distribution. exprnd raises an error if mu <= 0 to catch common parameter mistakes early.

What use cases does exprnd support?⌄

Common uses include queueing theory (M/M/1, M/G/1 inter-arrival and service times), reliability engineering (time-to-failure models), Poisson process simulation, and Monte Carlo sampling.

Does exprnd fuse with other operations?⌄

No. Random generation is excluded from fusion planning to preserve statistical properties.

How do I control reproducibility?⌄

Use rng before calling exprnd to seed the global generator.

Related Stats functions

Random

binornd · bootstrp · datasample · dividerand · gamrnd · lhsdesign · mvnrnd · normrnd · random · randsample · rng · trnd · unidrnd · unifrnd · wblrnd

Ml

bayesopt · classify · confusionmat · crossvalind · cvpartition · fitclinear · fitctree · fitlm · kmeans · knnsearch · lasso · lassoglm · linkage · lscov · mnrfit · optimizableVariable · pdist · pdist2 · perfcurve · predict · regress · ridge · squareform · test · training · tsne

Summary

binocdf · boxplot · cdf · cdfplot · chi2cdf · corr · corrcoef · corrcov · cov · cov2corr · dummyvar · ecdf · filloutliers · fitdist · geomean · grpstats · harmmean · icdf · isoutlier · kstest · kurtosis · lsline · mad · mode · nanmax · normalize · normcdf · norminv · normpdf · onehotdecode · onehotencode · pdf · prctile · quantile · refline · rmse · skewness · tabulate · tcdf · tiedrank · tinv · tpdf · ttest2 · wblinv

Hist

histc · histcounts · histcounts2

Options

statget · statset

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how exprnd is executed, line by line, in Rust.

  • View the source for exprnd in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How exprnd works
  • Examples
  • Single sample from Exp(2)
  • Matrix of arrival times for a Poisson process (lambda = 2)
  • M/M/1 queueing simulation fragment
  • Specifying dimensions with a size vector
  • Using exprnd with coding agents
  • FAQ
  • Related Stats functions
  • Random
  • Ml
  • Summary
  • Hist
  • Options
  • Open-source implementation
  • About RunMat