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

normrnd — Generate normally distributed random numbers in MATLAB and RunMat.

normrnd(mu, sigma, ...) draws pseudorandom samples from a normal distribution with scalar mean mu and standard deviation sigma. Scalar and vector size forms control the output shape.

Syntax

r = normrnd(mu, sigma)
r = normrnd(mu, sigma, sz)
r = normrnd(mu, sigma, sz1, sz2, ...)

Inputs

NameTypeRequiredDefaultDescription
muAnyYes—Mean parameter.
sigmaAnyYes—Standard deviation parameter (must be >= 0).
szAnyYes—Size scalar or size vector argument.
szAnyVariadic—Dimension extents for output shape.

Returns

NameTypeDescription
rNumericArrayRandom sample array from normal distribution.

Errors

IdentifierWhenMessage
RunMat:normrnd:SigmaMustBeNonnegativesigma is negative.normrnd: sigma must be non-negative
RunMat:normrnd:InvalidArgumentInput parameters or size arguments are missing or malformed.normrnd: invalid argument
RunMat:normrnd:InternalInternal conversion/allocation/provider decode fails.normrnd: internal operation failed

How normrnd works

  • normrnd(mu, sigma) returns a scalar drawn from N(mu, sigma^2).
  • normrnd(mu, sigma, n) returns an n × n matrix of samples.
  • normrnd(mu, sigma, m, n) returns an m × n matrix of samples.
  • normrnd(mu, sigma, sz) accepts a size vector and returns an array with shape sz.
  • mu and sigma must be scalar numeric values.
  • Current MATLAB documents single and double mu, sigma, and size values. Typed-integer and logical inputs are independently gated RunMat extensions; integer parameters must be exactly representable at the binary64 sampling boundary.
  • Integer size controls are parsed structurally and do not select output class or residency. Explicit resident size controls are a separate RunMat extension.
  • sigma must be non-negative; normrnd errors if sigma < 0.
  • Any single mu or sigma selects single output; otherwise output is double. A resident data parameter preserves output residency through its exact owner.

Examples

Single sample from N(0, 1)

rng(0);
r = normrnd(0, 1)

Matrix of Gaussian noise with mean 10 and standard deviation 2

rng(0);
X = normrnd(10, 2, 2, 3)

Simulating normally-distributed measurement errors

rng(0);
trueValue = 100;
sigma = 0.5;
measurements = trueValue + normrnd(0, sigma, 1, 5)

Specifying dimensions with a size vector

rng(0);
T = normrnd(5, 1.5, [2 3])

Using normrnd with coding agents

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

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

FAQ

What do mu and sigma mean?⌄

mu is the distribution mean and sigma is the standard deviation. The variance is sigma^2, so normrnd(mu, sigma) draws from N(mu, sigma^2).

What is the workaround if normrnd is unavailable?⌄

normrnd(mu, sigma) is mathematically equivalent to mu + sigma * randn(). For arrays, use mu + sigma * randn(sz) with the same requested size.

Can sigma be zero?⌄

Yes. sigma = 0 is allowed and returns deterministic samples equal to mu. Negative standard deviations are undefined and raise an error.

What use cases does normrnd support?⌄

Common uses include Gaussian noise generation, measurement error simulation, confidence interval experiments, Monte Carlo sampling, and normally-distributed model residuals.

Does normrnd 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 normrnd to seed the global generator.

Related Stats functions

Random

binornd · bootstrp · datasample · dividerand · exprnd · gamrnd · lhsdesign · mvnrnd · 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 normrnd is executed, line by line, in Rust.

  • View the source for normrnd 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 normrnd works
  • Examples
  • Single sample from N(0, 1)
  • Matrix of Gaussian noise with mean 10 and standard deviation 2
  • Simulating normally-distributed measurement errors
  • Specifying dimensions with a size vector
  • Using normrnd with coding agents
  • FAQ
  • Related Stats functions
  • Random
  • Ml
  • Summary
  • Hist
  • Options
  • Open-source implementation
  • About RunMat