Dist_scale¶
-
class
stats.
Dist_scale
(dist, loc_x=0, scale_x=1, scale_y=1, name=None)¶ Bases:
stats.Dist_qilum
Distribution scale for x and y: f_new = scale_y*f((x-loc_x)*scale_x)
- Parameters
dist (scipy stats distribution or Dist_qilum) –
loc_x (double) –
scale_x (double) – must be different of zero
scale_y (double) – must be strictly positive
name (string) – returned by
name()
Examples
>>> import qilum.stats as qs >>> import scipy.stats >>> # scipy dist >>> dist_exp = scipy.stats.expon() >>> # scale scipy dist with negative scale_x and multiplicative factor scale_y >>> dist = qs.Dist_scale(dist_exp, loc_x=5, scale_x=-1, scale_y=2)
Methods Summary
F_tot
()Cumulative of the function f() on the whole valid range x
cdf
(x)Cumulative distribution function.
f
(x)function f(x)
name
()Name of the class
pdf
(x)Probability density function
ppf
(q)Percent point function (inverse of cdf) at q
rvs
(size)random numbers in ndarray of lenght size
rvs_xy
(size)random numbers rans in ndarray of lenght size and function(rans)
Methods Documentation
-
F_tot
()¶ Cumulative of the function f() on the whole valid range x
- Returns
dist.F_tot()*scale_y*|scale_x|; if F_tot() not define set to 1
- Return type
int
Examples
>>> import qilum.stats as qs >>> import scipy.stats >>> dist = qs.Dist_scale(scipy.stats.expon(), loc_x=5, scale_x=-1, scale_y=2)) >>> print(dist.F_tot()) 2
-
cdf
(x)¶ Cumulative distribution function.
- Parameters
x (array_like of type(values)) –
- Returns
Cumulative distribution function evaluated at x
- Return type
ndarray
Examples
>>> import qilum.stats as qs >>> import scipy.stats >>> dist = qs.Dist_scale(scipy.stats.expon(), loc_x=5, scale_x=-1, scale_y=2)) >>> x = [0,1,2,3] >>> print('cdf(x)=',dist.cdf(x)) cdf(x)= [0.00673795 0.01831564 0.04978707 0.13533528]
-
f
(x)¶ function f(x)
- Parameters
x (array_like of type(values)) –
- Returns
f(x)
- Return type
ndarray
Examples
>>> import qilum.stats as qs >>> import scipy.stats >>> dist = qs.Dist_scale(scipy.stats.expon(), loc_x=5, scale_x=-1, scale_y=2)) >>> x = [0,1,2,3] >>> print('f(x)=',dist.f(x)) f(x)= [0.01347589 0.03663128 0.09957414 0.27067057]
-
name
()¶ Name of the class
- Returns
name if initialized; dist.name() if exists; ortherwise ‘Dist_scale’
- Return type
string
Examples
>>> import qilum.stats as qs >>> import scipy.stats >>> dist = qs.Dist_scale(scipy.stats.expon(), loc_x=5, scale_x=-1, scale_y=2, name='Exp_scaled')) >>> dist.name() 'Exp_scaled'
-
pdf
(x)¶ Probability density function
- Parameters
x (array_like of type(values)) –
- Returns
f(x)/F_tot()
- Return type
ndarray
Examples
>>> import qilum.stats as qs >>> import scipy.stats >>> dist = qs.Dist_scale(scipy.stats.expon(), loc_x=5, scale_x=-1, scale_y=2)) >>> x = [0,1,2,3] >>> print('pdf(x)=',dist.pdf(x)) pdf(x)= [0.00673795 0.01831564 0.04978707 0.13533528]
-
ppf
(q)¶ Percent point function (inverse of cdf) at q
- Parameters
q (array_like of double) – lower tail probability
- Returns
quantile corresponding to the lower tail probability q
- Return type
ndarray
Examples
>>> import qilum.stats as qs >>> import scipy.stats >>> dist = qs.Dist_scale(scipy.stats.expon(), loc_x=5, scale_x=-1, scale_y=2)) >>> q = [0, 0.3,0.5,0.7,1] >>> print('ppf(q)=',dist.ppf(q)) ppf(q)= [ -inf 3.7960272 4.30685282 4.64332506 5. ]
-
rvs
(size)¶ random numbers in ndarray of lenght size
- Parameters
size (int) – number of random number
- Returns
random numbers
- Return type
ndarray
Examples
>>> import qilum.stats as qs >>> import scipy.stats >>> dist = qs.Dist_scale(scipy.stats.expon(), loc_x=5, scale_x=-1, scale_y=2)) >>> print('rans=',dist.rvs(4)) rans= [4.19209864 3.58215396 4.37464038 3.62695892]
-
rvs_xy
(size)¶ random numbers rans in ndarray of lenght size and function(rans)
- Parameters
size (int) – number of random number
- Returns
ndarray – random numbers
ndarray – f(random numbers)
Examples
>>> import qilum.stats as qs >>> import scipy.stats >>> dist = qs.Dist_scale(scipy.stats.expon(), loc_x=5, scale_x=-1, scale_y=2)) >>> print('rans=',dist.rvs_xy(2)) rans= (array([4.58979217, 3.79870355]), array([1.32702468, 0.60160796]))