Fitting distributions

nuri. gaussian_fit ( mode , data , bins , xlim , order = 2 , reference = [] ) [source]

Gaussian fitting

class nuri.analysis.fitting. GaussianFit ( data , bins , xlim , order = 1 , reference = [] ) [source]

Fit Gaussian profile(s) to the distribution of magnetic field data.

Examples

>>> data = nuri.get_data('2016-3-14','2016-4-11','/content/drive/MyDrive/CityMagData/1Hz',station=2,sensor='biomed',scalar=True)
>>> x,y,y1,y2 = nuri.gaussian_fit(mode='gauss',data=data.value,bins=45,xlim=[48.8,50.3],order=2)
1/2 Gaussian : amp=140184.97, mu=49.55, sigma=0.212
2/2 Gaussian : amp=38811.87, mu=49.85, sigma=0.054

Methods Summary

__init__ (data, bins, xlim[, order, reference])

Initialize Gaussian fitting class.

gauss_single (x, amp, mu, sigma)

gauss_fct (x, *params)

gauss_fit (x, y, params)

get_params ()

get_fit ()

Methods Documentation

__init__ ( data , bins , xlim , order = 1 , reference = [] ) [source]

Initialize Gaussian fitting class. When 2 Gaussian profiles are being fitted, i.e., order is equal to 2, and a reference dataset is provide, a single Gaussian profile will first be fitted to the reference data; a double Gaussian profile will then be fitted to the entire input dataset with the parameters from the reference profile being fixed.

Parameters :
data numpy.ndarray

Input magnetic field data.

bins int

Number of bins in the histogram.

xlim list [ float ]

Range to generate histograms from the data.

order int

Number of Gaussian profiles to fit the data with.

reference list [ float ]

Reference dataset to fit the first Gaussian profile.

gauss_single ( x , amp , mu , sigma ) [source]
gauss_fct ( x , * params ) [source]
gauss_fit ( x , y , params ) [source]
get_params ( ) [source]
get_fit ( ) [source]

Skewed Gaussian fitting

class nuri.analysis.fitting. SkewedGaussianFit ( data , bins , xlim , order = 1 , reference = [] ) [source]

Fitting data distribution with skewed Gaussian profiles.

Methods Summary

__init__ (data, bins, xlim[, order, reference])

skew_single (x, amp, mu, sigma, skewness)

A skewed Gaussian model, using a skewed normal distribution.

skew_fct (x, *params)

skew_fit (x, y, params)

get_params ()

get_fit ()

Methods Documentation

__init__ ( data , bins , xlim , order = 1 , reference = [] ) [source]
skew_single ( x , amp , mu , sigma , skewness ) [source]

A skewed Gaussian model, using a skewed normal distribution. The model has four Parameters: amplitude ( \(A\) ), center ( \(\mu\) ), sigma ( \(\sigma\) ), and gamma ( \(\gamma\) ).

\[f(x; A, \mu, \sigma, \gamma) = \frac{A}{\sigma\sqrt{2\pi}} e^{[{-{(x-\mu)^2}/{{2\sigma}^2}}]} \Bigl\{ 1 + {\operatorname{erf}}\bigl[ \frac{{\gamma}(x-\mu)}{\sigma\sqrt{2}} \bigr] \Bigr\}\]

where erf() is the error function. For more information, see: https://en.wikipedia.org/wiki/Skew_normal_distribution

skew_fct ( x , * params ) [source]
skew_fit ( x , y , params ) [source]
get_params ( ) [source]
get_fit ( ) [source]

Independent Skewed Gaussian

class nuri.analysis.fitting. IndSkewedGaussian ( data , bins , xlim , order = 1 , reference = [] ) [source]

Fitting independently day and night distributions using skewed Gaussian profiles.

Examples

>>> data = nuri.get_data('2016-3-14','2016-4-11','/content/drive/MyDrive/CityMagData/1Hz',station=2,sensor='biomed',scalar=True)
>>> day, night = nuri.day_and_night(data.value,daytime=[[0,1],[4.5,24]])
>>> x,y,y1,y2 = nuri.gaussian_fit(mode='indskew',data=data.value,bins=45,xlim=[48.8,50.3],order=2,reference=[day,night]).get_fit()
1/1 Gaussian (skewed) : amp=67980.04, mu=49.36, sigma=0.281, skewness=1.393503
1/1 Gaussian (skewed) : amp=11488.11, mu=49.92, sigma=0.212, skewness=-4.605114

Methods Summary

__init__ (data, bins, xlim[, order, reference])

skew_single (x, amp, mu, sigma, skewness)

skew_fct (x, *params)

get_fit ()

Methods Documentation

__init__ ( data , bins , xlim , order = 1 , reference = [] ) [source]
skew_single ( x , amp , mu , sigma , skewness ) [source]
skew_fct ( x , * params ) [source]
get_fit ( ) [source]

Mixed Gaussian fitting

class nuri.analysis.fitting. MixedGaussianFit ( data , bins , xlim , reference = [] ) [source]

Methods Summary

__init__ (data, bins, xlim[, reference])

gauss_fct (x, *params)

skew_fct (x, *params)

mix_fct (x, *params)

mix_fit (x, y, params)

get_fit ()

Methods Documentation

__init__ ( data , bins , xlim , reference = [] ) [source]
gauss_fct ( x , * params ) [source]
skew_fct ( x , * params ) [source]
mix_fct ( x , * params ) [source]
mix_fit ( x , y , params ) [source]
get_fit ( ) [source]