fitdist — Fit a probability distribution object to sample data.

fitdist(x,distname) estimates distribution parameters from vector data and returns a ProbabilityDistribution object accepted by pdf, cdf, icdf, and random.

Syntax

pd = fitdist(x, distname)
pd = fitdist(x, distname, Name, Value)

Inputs

NameTypeRequiredDefaultDescription
xNumericArrayYesSample data or evaluation points.
distnameStringScalarYesDistribution name.
NameValueAnyVariadicName-value options.

Returns

NameTypeDescription
pdAnyFitted probability distribution object.

Errors

IdentifierWhenMessage
RunMat:fitdist:InvalidArgumentSample data, distribution name, options, or evaluation inputs are malformed.fitdist: invalid argument
RunMat:fitdist:NumericalDistribution parameter estimation fails to converge or is ill-conditioned.fitdist: numerical failure
RunMat:fitdist:InternalRunMat cannot construct distribution outputs.fitdist: internal error

How fitdist works

  • Supported fitted distributions are "Normal", "Exponential", "Lognormal", "Gamma", "Weibull", and "Poisson"; common short aliases such as "norm", "exp", "logn", "gam", "wbl", and "poiss" are accepted.
  • Input data must be a numeric vector. NaN observations are ignored and Inf observations are rejected.
  • fitdist(x,distname,"Frequency",w) accepts nonnegative finite observation weights with one weight per observation. Zero-weight observations are ignored.
  • Range constraints follow the selected distribution: exponential data must be nonnegative, lognormal/gamma/weibull data must be positive, and Poisson data must be nonnegative integers.
  • The returned object exposes DistributionName, DistName, ParameterNames, ParameterValues, NumParameters, NumObservations, NLogL, IsTruncated, and scalar parameter properties such as mu, sigma, lambda, a, or b.

Examples

Fit a normal distribution and evaluate it

pd = fitdist([1;2;3], "Normal"); y = pdf(pd, 2); p = cdf(pd, 2); x = icdf(pd, 0.5)

Fit with observation frequencies

pd = fitdist([1;2], "Exponential", "Frequency", [1;3])

Using fitdist with coding agents

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

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

FAQ

Does fitdist support censoring or custom optimization options?

Not yet. Censoring, Options, and grouped By fits are rejected explicitly rather than ignored.

Open-source implementation

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

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.