Loading [MathJax]/extensions/tex2jax.js
scipy 1.10.1 Pypi GitHub Homepage
Other Docs

NotesParametersRaisesReturns
norm_gen.fit(self, data, **kwds)

Starting estimates for the fit are given by input arguments; for any arguments not provided with starting estimates, self._fitstart(data) is called to generate such.

One can hold some parameters fixed to specific values by passing in keyword arguments f0, f1, ..., fn (for shape parameters) and floc and fscale (for location and scale parameters, respectively).

Notes

For the normal distribution, method of moments and maximum likelihood estimation give identical fits, and explicit formulas for the estimates are available. This function uses these explicit formulas for the maximum likelihood estimation of the normal distribution parameters, so the optimizer and method arguments are ignored.

Parameters

data : array_like

Data to use in estimating the distribution parameters.

arg1, arg2, arg3,... : floats, optional

Starting value(s) for any shape-characterizing arguments (those not provided will be determined by a call to _fitstart(data)). No default value.

**kwds : floats, optional
  • loc: initial guess of the distribution's location parameter.
  • scale: initial guess of the distribution's scale parameter.

Special keyword arguments are recognized as holding certain parameters fixed:

Raises

TypeError, ValueError

If an input is invalid

`~scipy.stats.FitError`

If fitting fails or the fit produced would be invalid

Returns

parameter_tuple : tuple of floats

Estimates for any shape parameters (if applicable), followed by those for location and scale. For most random variables, shape statistics will be returned, but there are exceptions (e.g. norm).

Return estimates of shape (if applicable), location, and scale parameters from data. The default estimation method is Maximum Likelihood Estimation (MLE), but Method of Moments (MM) is also available.

Examples

Generate some data to fit: draw random variates from the `beta` distribution
from scipy.stats import beta
a, b = 1., 2.
x = beta.rvs(a, b, size=1000)
Now we can fit all four parameters (``a``, ``b``, ``loc`` and ``scale``):
a1, b1, loc1, scale1 = beta.fit(x)
We can also use some prior knowledge about the dataset: let's keep ``loc`` and ``scale`` fixed:
a1, b1, loc1, scale1 = beta.fit(x, floc=0, fscale=1)
loc1, scale1
We can also keep shape parameters fixed by using ``f``-keywords. To keep the zero-th shape parameter ``a`` equal 1, use ``f0=1`` or, equivalently, ``fa=1``:
a1, b1, loc1, scale1 = beta.fit(x, fa=1, floc=0, fscale=1)
a1
Not all distributions return estimates for the shape parameters. ``norm`` for example just returns estimates for location and scale:
from scipy.stats import norm
x = norm.rvs(a, b, size=1000, random_state=123)
loc1, scale1 = norm.fit(x)
loc1, scale1
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

scipy.sparse._data:_create_method.<locals>.methodmethod

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/stats/_continuous_distns.py#383
type: <class 'function'>
Commit: