schrodinger.application.matsci.gsas.GSASIIpwd module¶
# Third-party code. No Schrodinger Copyright.
GSASII powder calculation module¶
- schrodinger.application.matsci.gsas.GSASIIpwd.tand(x)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.atand(x)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.atan2d(y, x)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.cosd(x)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.acosd(x)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.rdsq2d(x, p)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.npsind(x)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.npasind(x)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.npcosd(x)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.npacosd(x)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.nptand(x)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.npatand(x)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.npatan2d(y, x)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.npT2stl(tth, wave)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.npT2q(tth, wave)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.PhaseWtSum(G2frame, histo)¶
Calculate sum of phase mass*phase fraction for PWDR data (exclude magnetic phases)
- Parameters
G2frame – GSASII main frame structure
histo (str) – histogram name
- Returns
sum(scale*mass) for phases in histo
- schrodinger.application.matsci.gsas.GSASIIpwd.Transmission(Geometry, Abs, Diam)¶
Calculate sample transmission
- Parameters
Geometry (str) – one of ‘Cylinder’,’Bragg-Brentano’,’Tilting flat plate in transmission’,’Fixed flat plate’
Abs (float) – absorption coeff in cm-1
Diam (float) – sample thickness/diameter in mm
- schrodinger.application.matsci.gsas.GSASIIpwd.SurfaceRough(SRA, SRB, Tth)¶
Suortti (J. Appl. Cryst, 5,325-331, 1972) surface roughness correction :param float SRA: Suortti surface roughness parameter :param float SRB: Suortti surface roughness parameter :param float Tth: 2-theta(deg) - can be numpy array
- schrodinger.application.matsci.gsas.GSASIIpwd.SurfaceRoughDerv(SRA, SRB, Tth)¶
Suortti surface roughness correction derivatives :param float SRA: Suortti surface roughness parameter (dimensionless) :param float SRB: Suortti surface roughness parameter (dimensionless) :param float Tth: 2-theta(deg) - can be numpy array :return list: [dydSRA,dydSRB] derivatives to be used for intensity derivative
- schrodinger.application.matsci.gsas.GSASIIpwd.Absorb(Geometry, MuR, Tth, Phi=0, Psi=0)¶
Calculate sample absorption :param str Geometry: one of ‘Cylinder’,’Bragg-Brentano’,’Tilting Flat Plate in transmission’,’Fixed flat plate’ :param float MuR: absorption coeff * sample thickness/2 or radius :param Tth: 2-theta scattering angle - can be numpy array :param float Phi: flat plate tilt angle - future :param float Psi: flat plate tilt axis - future
- schrodinger.application.matsci.gsas.GSASIIpwd.AbsorbDerv(Geometry, MuR, Tth, Phi=0, Psi=0)¶
needs a doc string
- schrodinger.application.matsci.gsas.GSASIIpwd.Polarization(Pola, Tth, Azm=0.0)¶
Calculate angle dependent x-ray polarization correction (not scaled correctly!)
- Parameters
Pola – polarization coefficient e.g 1.0 fully polarized, 0.5 unpolarized
Azm – azimuthal angle e.g. 0.0 in plane of polarization
Tth – 2-theta scattering angle - can be numpy array which (if either) of these is “right”?
- Returns
(pola, dpdPola) * pola = ((1-Pola)*npcosd(Azm)**2+Pola*npsind(Azm)**2)*npcosd(Tth)**2+ (1-Pola)*npsind(Azm)**2+Pola*npcosd(Azm)**2 * dpdPola: derivative needed for least squares
- schrodinger.application.matsci.gsas.GSASIIpwd.Oblique(ObCoeff, Tth)¶
currently assumes detector is normal to beam
- schrodinger.application.matsci.gsas.GSASIIpwd.Ruland(RulCoff, wave, Q, Compton)¶
needs a doc string
- schrodinger.application.matsci.gsas.GSASIIpwd.LorchWeight(Q)¶
needs a doc string
- schrodinger.application.matsci.gsas.GSASIIpwd.GetAsfMean(ElList, Sthl2)¶
Calculate various scattering factor terms for PDF calcs
- Parameters
ElList (dict) – element dictionary contains scattering factor coefficients, etc.
Sthl2 (np.array) – numpy array of sin theta/lambda squared values
- Returns
mean(f^2), mean(f)^2, mean(compton)
- schrodinger.application.matsci.gsas.GSASIIpwd.GetNumDensity(ElList, Vol)¶
needs a doc string
- schrodinger.application.matsci.gsas.GSASIIpwd.CalcPDF(data, inst, limits, xydata)¶
Computes I(Q), S(Q) & G(r) from Sample, Bkg, etc. diffraction patterns loaded into dict xydata; results are placed in xydata. Calculation parameters are found in dicts data and inst and list limits. The return value is at present an empty list.
- schrodinger.application.matsci.gsas.GSASIIpwd.PDFPeakFit(peaks, data)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.MakeRDF(RDFcontrols, background, inst, pwddata)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.OptimizePDF(data, xydata, limits, inst, showFit=True, maxCycles=5)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.SetupPDFEval(data, xydata, limits, inst, numbDen)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.factorize(num)¶
Provide prime number factors for integer num :returns: dictionary of prime factors (keys) & power for each (data)
- schrodinger.application.matsci.gsas.GSASIIpwd.makeFFTsizeList(nmin=1, nmax=1023, thresh=15)¶
Provide list of optimal data sizes for FFT calculations
- Parameters
nmin (int) – minimum data size >= 1
nmax (int) – maximum data size > nmin
thresh (int) – maximum prime factor allowed
- Returns
list of data sizes where the maximum prime factor is < thresh
- class schrodinger.application.matsci.gsas.GSASIIpwd.norm_gen(momtype=1, a=None, b=None, xtol=1e-14, badvalue=None, name=None, longname=None, shapes=None, extradoc=None, seed=None)¶
Bases:
scipy.stats._distn_infrastructure.rv_continuous
needs a doc string
- pdf(x, *args, **kwds)¶
Probability density function at x of the given RV.
- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- pdfndarray
Probability density function evaluated at x
- __init__(momtype=1, a=None, b=None, xtol=1e-14, badvalue=None, name=None, longname=None, shapes=None, extradoc=None, seed=None)¶
- cdf(x, *args, **kwds)¶
Cumulative distribution function of the given RV.
- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- cdfndarray
Cumulative distribution function evaluated at
x
- entropy(*args, **kwds)¶
Differential entropy of the RV.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- locarray_like, optional
Location parameter (default=0).
- scalearray_like, optional (continuous distributions only).
Scale parameter (default=1).
Entropy is defined base
e
:>>> import numpy as np >>> drv = rv_discrete(values=((0, 1), (0.5, 0.5))) >>> np.allclose(drv.entropy(), np.log(2.0)) True
- expect(func=None, args=(), loc=0, scale=1, lb=None, ub=None, conditional=False, **kwds)¶
Calculate expected value of a function with respect to the distribution by numerical integration.
The expected value of a function
f(x)
with respect to a distributiondist
is defined as:ub E[f(x)] = Integral(f(x) * dist.pdf(x)), lb
where
ub
andlb
are arguments andx
has thedist.pdf(x)
distribution. If the boundslb
andub
correspond to the support of the distribution, e.g.[-inf, inf]
in the default case, then the integral is the unrestricted expectation off(x)
. Also, the functionf(x)
may be defined such thatf(x)
is0
outside a finite interval in which case the expectation is calculated within the finite range[lb, ub]
.- funccallable, optional
Function for which integral is calculated. Takes only one argument. The default is the identity mapping f(x) = x.
- argstuple, optional
Shape parameters of the distribution.
- locfloat, optional
Location parameter (default=0).
- scalefloat, optional
Scale parameter (default=1).
- lb, ubscalar, optional
Lower and upper bound for integration. Default is set to the support of the distribution.
- conditionalbool, optional
If True, the integral is corrected by the conditional probability of the integration interval. The return value is the expectation of the function, conditional on being in the given interval. Default is False.
Additional keyword arguments are passed to the integration routine.
- expectfloat
The calculated expected value.
The integration behavior of this function is inherited from
scipy.integrate.quad
. Neither this function norscipy.integrate.quad
can verify whether the integral exists or is finite. For examplecauchy(0).mean()
returnsnp.nan
andcauchy(0).expect()
returns0.0
.Likewise, the accuracy of results is not verified by the function.
scipy.integrate.quad
is typically reliable for integrals that are numerically favorable, but it is not guaranteed to converge to a correct value for all possible intervals and integrands. This function is provided for convenience; for critical applications, check results against other integration methods.The function is not vectorized.
To understand the effect of the bounds of integration consider
>>> from scipy.stats import expon >>> expon(1).expect(lambda x: 1, lb=0.0, ub=2.0) 0.6321205588285578
This is close to
>>> expon(1).cdf(2.0) - expon(1).cdf(0.0) 0.6321205588285577
If
conditional=True
>>> expon(1).expect(lambda x: 1, lb=0.0, ub=2.0, conditional=True) 1.0000000000000002
The slight deviation from 1 is due to numerical integration.
The integrand can be treated as a complex-valued function by passing
complex_func=True
toscipy.integrate.quad
.>>> import numpy as np >>> from scipy.stats import vonmises >>> res = vonmises(loc=2, kappa=1).expect(lambda x: np.exp(1j*x), ... complex_func=True) >>> res (-0.18576377217422957+0.40590124735052263j)
>>> np.angle(res) # location of the (circular) distribution 2.0
- fit(data, *args, **kwds)¶
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.
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) andfloc
andfscale
(for location and scale parameters, respectively).- dataarray_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.- **kwdsfloats, 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:
f0…fn : hold respective shape parameters fixed. Alternatively, shape parameters to fix can be specified by name. For example, if
self.shapes == "a, b"
,fa
andfix_a
are equivalent tof0
, andfb
andfix_b
are equivalent tof1
.floc : hold location parameter fixed to specified value.
fscale : hold scale parameter fixed to specified value.
optimizer : The optimizer to use. The optimizer must take
func
, and starting position as the first two arguments, plusargs
(for extra arguments to pass to the function to be optimized) anddisp=0
to suppress output as keyword arguments.method : The method to use. The default is “MLE” (Maximum Likelihood Estimate); “MM” (Method of Moments) is also available.
- TypeError, ValueError
If an input is invalid
FitError
If fitting fails or the fit produced would be invalid
- parameter_tupletuple 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
).
With
method="MLE"
(default), the fit is computed by minimizing the negative log-likelihood function. A large, finite penalty (rather than infinite negative log-likelihood) is applied for observations beyond the support of the distribution.With
method="MM"
, the fit is computed by minimizing the L2 norm of the relative errors between the first k raw (about zero) data moments and the corresponding distribution moments, where k is the number of non-fixed parameters. More precisely, the objective function is:(((data_moments - dist_moments) / np.maximum(np.abs(data_moments), 1e-8))**2).sum()
where the constant
1e-8
avoids division by zero in case of vanishing data moments. Typically, this error norm can be reduced to zero. Note that the standard method of moments can produce parameters for which some data are outside the support of the fitted distribution; this implementation does nothing to prevent this.For either method, the returned answer is not guaranteed to be globally optimal; it may only be locally optimal, or the optimization may fail altogether. If the data contain any of
np.nan
,np.inf
, or-np.inf
, thefit
method will raise aRuntimeError
.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
andscale
):>>> a1, b1, loc1, scale1 = beta.fit(x)
We can also use some prior knowledge about the dataset: let’s keep
loc
andscale
fixed:>>> a1, b1, loc1, scale1 = beta.fit(x, floc=0, fscale=1) >>> loc1, scale1 (0, 1)
We can also keep shape parameters fixed by using
f
-keywords. To keep the zero-th shape parametera
equal 1, usef0=1
or, equivalently,fa=1
:>>> a1, b1, loc1, scale1 = beta.fit(x, fa=1, floc=0, fscale=1) >>> a1 1
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 (0.92087172783841631, 2.0015750750324668)
- fit_loc_scale(data, *args)¶
Estimate loc and scale parameters from data using 1st and 2nd moments.
- dataarray_like
Data to fit.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- Lhatfloat
Estimated location parameter for the data.
- Shatfloat
Estimated scale parameter for the data.
- freeze(*args, **kwds)¶
Freeze the distribution for the given arguments.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution. Should include all the non-optional arguments, may include
loc
andscale
.
- rv_frozenrv_frozen instance
The frozen distribution.
- interval(confidence=None, *args, **kwds)¶
Confidence interval with equal areas around the median.
Deprecated since version 1.9.0: Parameter
alpha
is replaced by parameterconfidence
to avoid name collisions with the shape parameteralpha
of some distributions. Parameteralpha
will be removed in SciPy 1.11.0.- confidencearray_like of float
Probability that an rv will be drawn from the returned range. Each value should be in the range [0, 1].
- arg1, arg2, …array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- locarray_like, optional
location parameter, Default is 0.
- scalearray_like, optional
scale parameter, Default is 1.
- a, bndarray of float
end-points of range that contain
100 * alpha %
of the rv’s possible values.
This is implemented as
ppf([p_tail, 1-p_tail])
, whereppf
is the inverse cumulative distribution function andp_tail = (1-confidence)/2
. Suppose[c, d]
is the support of a discrete distribution; thenppf([0, 1]) == (c-1, d)
. Therefore, whenconfidence=1
and the distribution is discrete, the left end of the interval will be beyond the support of the distribution. For discrete distributions, the interval will limit the probability in each tail to be less than or equal top_tail
(usually strictly less).
- isf(q, *args, **kwds)¶
Inverse survival function (inverse of
sf
) at q of the given RV.- qarray_like
upper tail probability
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- xndarray or scalar
Quantile corresponding to the upper tail probability q.
- logcdf(x, *args, **kwds)¶
Log of the cumulative distribution function at x of the given RV.
- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- logcdfarray_like
Log of the cumulative distribution function evaluated at x
- logpdf(x, *args, **kwds)¶
Log of the probability density function at x of the given RV.
This uses a more numerically accurate calculation if available.
- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- logpdfarray_like
Log of the probability density function evaluated at x
- logsf(x, *args, **kwds)¶
Log of the survival function of the given RV.
Returns the log of the “survival function,” defined as (1 -
cdf
), evaluated atx
.- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- logsfndarray
Log of the survival function evaluated at
x
.
- mean(*args, **kwds)¶
Mean of the distribution.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- meanfloat
the mean of the distribution
- median(*args, **kwds)¶
Median of the distribution.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
Location parameter, Default is 0.
- scalearray_like, optional
Scale parameter, Default is 1.
- medianfloat
The median of the distribution.
- rv_discrete.ppf
Inverse of the CDF
- moment(order=None, *args, **kwds)¶
non-central moment of distribution of specified order.
Deprecated since version 1.9.0: Parameter
n
is replaced by parameterorder
to avoid name collisions with the shape parametern
of several distributions. Parametern
will be removed in SciPy 1.11.0.- orderint, order >= 1
Order of moment.
- arg1, arg2, arg3,…float
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- nnlf(theta, x)¶
Negative loglikelihood function. Notes —– This is
-sum(log pdf(x, theta), axis=0)
wheretheta
are the parameters (including loc and scale).
- ppf(q, *args, **kwds)¶
Percent point function (inverse of
cdf
) at q of the given RV.- qarray_like
lower tail probability
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- xarray_like
quantile corresponding to the lower tail probability q.
- property random_state¶
Get or set the generator object for generating random variates.
If
random_state
is None (ornp.random
), thenumpy.random.RandomState
singleton is used. Ifrandom_state
is an int, a newRandomState
instance is used, seeded withrandom_state
. Ifrandom_state
is already aGenerator
orRandomState
instance, that instance is used.
- rvs(*args, **kwds)¶
Random variates of given type.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- locarray_like, optional
Location parameter (default=0).
- scalearray_like, optional
Scale parameter (default=1).
- sizeint or tuple of ints, optional
Defining number of random variates (default is 1).
- random_state{None, int,
numpy.random.Generator
, numpy.random.RandomState
}, optionalIf
random_state
is None (ornp.random
), thenumpy.random.RandomState
singleton is used. Ifrandom_state
is an int, a newRandomState
instance is used, seeded withrandom_state
. Ifrandom_state
is already aGenerator
orRandomState
instance, that instance is used.
- rvsndarray or scalar
Random variates of given
size
.
- sf(x, *args, **kwds)¶
Survival function (1 -
cdf
) at x of the given RV.- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- sfarray_like
Survival function evaluated at x
- stats(*args, **kwds)¶
Some statistics of the given RV.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional (continuous RVs only)
scale parameter (default=1)
- momentsstr, optional
composed of letters [‘mvsk’] defining which moments to compute: ‘m’ = mean, ‘v’ = variance, ‘s’ = (Fisher’s) skew, ‘k’ = (Fisher’s) kurtosis. (default is ‘mv’)
- statssequence
of requested moments.
- std(*args, **kwds)¶
Standard deviation of the distribution.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- stdfloat
standard deviation of the distribution
- support(*args, **kwargs)¶
Support of the distribution.
- arg1, arg2, …array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- locarray_like, optional
location parameter, Default is 0.
- scalearray_like, optional
scale parameter, Default is 1.
- a, barray_like
end-points of the distribution’s support.
- var(*args, **kwds)¶
Variance of the distribution.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- varfloat
the variance of the distribution
- class schrodinger.application.matsci.gsas.GSASIIpwd.cauchy_gen(momtype=1, a=None, b=None, xtol=1e-14, badvalue=None, name=None, longname=None, shapes=None, extradoc=None, seed=None)¶
Bases:
scipy.stats._distn_infrastructure.rv_continuous
needs a doc string
- pdf(x, *args, **kwds)¶
Probability density function at x of the given RV.
- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- pdfndarray
Probability density function evaluated at x
- __init__(momtype=1, a=None, b=None, xtol=1e-14, badvalue=None, name=None, longname=None, shapes=None, extradoc=None, seed=None)¶
- cdf(x, *args, **kwds)¶
Cumulative distribution function of the given RV.
- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- cdfndarray
Cumulative distribution function evaluated at
x
- entropy(*args, **kwds)¶
Differential entropy of the RV.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- locarray_like, optional
Location parameter (default=0).
- scalearray_like, optional (continuous distributions only).
Scale parameter (default=1).
Entropy is defined base
e
:>>> import numpy as np >>> drv = rv_discrete(values=((0, 1), (0.5, 0.5))) >>> np.allclose(drv.entropy(), np.log(2.0)) True
- expect(func=None, args=(), loc=0, scale=1, lb=None, ub=None, conditional=False, **kwds)¶
Calculate expected value of a function with respect to the distribution by numerical integration.
The expected value of a function
f(x)
with respect to a distributiondist
is defined as:ub E[f(x)] = Integral(f(x) * dist.pdf(x)), lb
where
ub
andlb
are arguments andx
has thedist.pdf(x)
distribution. If the boundslb
andub
correspond to the support of the distribution, e.g.[-inf, inf]
in the default case, then the integral is the unrestricted expectation off(x)
. Also, the functionf(x)
may be defined such thatf(x)
is0
outside a finite interval in which case the expectation is calculated within the finite range[lb, ub]
.- funccallable, optional
Function for which integral is calculated. Takes only one argument. The default is the identity mapping f(x) = x.
- argstuple, optional
Shape parameters of the distribution.
- locfloat, optional
Location parameter (default=0).
- scalefloat, optional
Scale parameter (default=1).
- lb, ubscalar, optional
Lower and upper bound for integration. Default is set to the support of the distribution.
- conditionalbool, optional
If True, the integral is corrected by the conditional probability of the integration interval. The return value is the expectation of the function, conditional on being in the given interval. Default is False.
Additional keyword arguments are passed to the integration routine.
- expectfloat
The calculated expected value.
The integration behavior of this function is inherited from
scipy.integrate.quad
. Neither this function norscipy.integrate.quad
can verify whether the integral exists or is finite. For examplecauchy(0).mean()
returnsnp.nan
andcauchy(0).expect()
returns0.0
.Likewise, the accuracy of results is not verified by the function.
scipy.integrate.quad
is typically reliable for integrals that are numerically favorable, but it is not guaranteed to converge to a correct value for all possible intervals and integrands. This function is provided for convenience; for critical applications, check results against other integration methods.The function is not vectorized.
To understand the effect of the bounds of integration consider
>>> from scipy.stats import expon >>> expon(1).expect(lambda x: 1, lb=0.0, ub=2.0) 0.6321205588285578
This is close to
>>> expon(1).cdf(2.0) - expon(1).cdf(0.0) 0.6321205588285577
If
conditional=True
>>> expon(1).expect(lambda x: 1, lb=0.0, ub=2.0, conditional=True) 1.0000000000000002
The slight deviation from 1 is due to numerical integration.
The integrand can be treated as a complex-valued function by passing
complex_func=True
toscipy.integrate.quad
.>>> import numpy as np >>> from scipy.stats import vonmises >>> res = vonmises(loc=2, kappa=1).expect(lambda x: np.exp(1j*x), ... complex_func=True) >>> res (-0.18576377217422957+0.40590124735052263j)
>>> np.angle(res) # location of the (circular) distribution 2.0
- fit(data, *args, **kwds)¶
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.
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) andfloc
andfscale
(for location and scale parameters, respectively).- dataarray_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.- **kwdsfloats, 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:
f0…fn : hold respective shape parameters fixed. Alternatively, shape parameters to fix can be specified by name. For example, if
self.shapes == "a, b"
,fa
andfix_a
are equivalent tof0
, andfb
andfix_b
are equivalent tof1
.floc : hold location parameter fixed to specified value.
fscale : hold scale parameter fixed to specified value.
optimizer : The optimizer to use. The optimizer must take
func
, and starting position as the first two arguments, plusargs
(for extra arguments to pass to the function to be optimized) anddisp=0
to suppress output as keyword arguments.method : The method to use. The default is “MLE” (Maximum Likelihood Estimate); “MM” (Method of Moments) is also available.
- TypeError, ValueError
If an input is invalid
FitError
If fitting fails or the fit produced would be invalid
- parameter_tupletuple 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
).
With
method="MLE"
(default), the fit is computed by minimizing the negative log-likelihood function. A large, finite penalty (rather than infinite negative log-likelihood) is applied for observations beyond the support of the distribution.With
method="MM"
, the fit is computed by minimizing the L2 norm of the relative errors between the first k raw (about zero) data moments and the corresponding distribution moments, where k is the number of non-fixed parameters. More precisely, the objective function is:(((data_moments - dist_moments) / np.maximum(np.abs(data_moments), 1e-8))**2).sum()
where the constant
1e-8
avoids division by zero in case of vanishing data moments. Typically, this error norm can be reduced to zero. Note that the standard method of moments can produce parameters for which some data are outside the support of the fitted distribution; this implementation does nothing to prevent this.For either method, the returned answer is not guaranteed to be globally optimal; it may only be locally optimal, or the optimization may fail altogether. If the data contain any of
np.nan
,np.inf
, or-np.inf
, thefit
method will raise aRuntimeError
.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
andscale
):>>> a1, b1, loc1, scale1 = beta.fit(x)
We can also use some prior knowledge about the dataset: let’s keep
loc
andscale
fixed:>>> a1, b1, loc1, scale1 = beta.fit(x, floc=0, fscale=1) >>> loc1, scale1 (0, 1)
We can also keep shape parameters fixed by using
f
-keywords. To keep the zero-th shape parametera
equal 1, usef0=1
or, equivalently,fa=1
:>>> a1, b1, loc1, scale1 = beta.fit(x, fa=1, floc=0, fscale=1) >>> a1 1
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 (0.92087172783841631, 2.0015750750324668)
- fit_loc_scale(data, *args)¶
Estimate loc and scale parameters from data using 1st and 2nd moments.
- dataarray_like
Data to fit.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- Lhatfloat
Estimated location parameter for the data.
- Shatfloat
Estimated scale parameter for the data.
- freeze(*args, **kwds)¶
Freeze the distribution for the given arguments.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution. Should include all the non-optional arguments, may include
loc
andscale
.
- rv_frozenrv_frozen instance
The frozen distribution.
- interval(confidence=None, *args, **kwds)¶
Confidence interval with equal areas around the median.
Deprecated since version 1.9.0: Parameter
alpha
is replaced by parameterconfidence
to avoid name collisions with the shape parameteralpha
of some distributions. Parameteralpha
will be removed in SciPy 1.11.0.- confidencearray_like of float
Probability that an rv will be drawn from the returned range. Each value should be in the range [0, 1].
- arg1, arg2, …array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- locarray_like, optional
location parameter, Default is 0.
- scalearray_like, optional
scale parameter, Default is 1.
- a, bndarray of float
end-points of range that contain
100 * alpha %
of the rv’s possible values.
This is implemented as
ppf([p_tail, 1-p_tail])
, whereppf
is the inverse cumulative distribution function andp_tail = (1-confidence)/2
. Suppose[c, d]
is the support of a discrete distribution; thenppf([0, 1]) == (c-1, d)
. Therefore, whenconfidence=1
and the distribution is discrete, the left end of the interval will be beyond the support of the distribution. For discrete distributions, the interval will limit the probability in each tail to be less than or equal top_tail
(usually strictly less).
- isf(q, *args, **kwds)¶
Inverse survival function (inverse of
sf
) at q of the given RV.- qarray_like
upper tail probability
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- xndarray or scalar
Quantile corresponding to the upper tail probability q.
- logcdf(x, *args, **kwds)¶
Log of the cumulative distribution function at x of the given RV.
- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- logcdfarray_like
Log of the cumulative distribution function evaluated at x
- logpdf(x, *args, **kwds)¶
Log of the probability density function at x of the given RV.
This uses a more numerically accurate calculation if available.
- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- logpdfarray_like
Log of the probability density function evaluated at x
- logsf(x, *args, **kwds)¶
Log of the survival function of the given RV.
Returns the log of the “survival function,” defined as (1 -
cdf
), evaluated atx
.- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- logsfndarray
Log of the survival function evaluated at
x
.
- mean(*args, **kwds)¶
Mean of the distribution.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- meanfloat
the mean of the distribution
- median(*args, **kwds)¶
Median of the distribution.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
Location parameter, Default is 0.
- scalearray_like, optional
Scale parameter, Default is 1.
- medianfloat
The median of the distribution.
- rv_discrete.ppf
Inverse of the CDF
- moment(order=None, *args, **kwds)¶
non-central moment of distribution of specified order.
Deprecated since version 1.9.0: Parameter
n
is replaced by parameterorder
to avoid name collisions with the shape parametern
of several distributions. Parametern
will be removed in SciPy 1.11.0.- orderint, order >= 1
Order of moment.
- arg1, arg2, arg3,…float
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- nnlf(theta, x)¶
Negative loglikelihood function. Notes —– This is
-sum(log pdf(x, theta), axis=0)
wheretheta
are the parameters (including loc and scale).
- ppf(q, *args, **kwds)¶
Percent point function (inverse of
cdf
) at q of the given RV.- qarray_like
lower tail probability
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- xarray_like
quantile corresponding to the lower tail probability q.
- property random_state¶
Get or set the generator object for generating random variates.
If
random_state
is None (ornp.random
), thenumpy.random.RandomState
singleton is used. Ifrandom_state
is an int, a newRandomState
instance is used, seeded withrandom_state
. Ifrandom_state
is already aGenerator
orRandomState
instance, that instance is used.
- rvs(*args, **kwds)¶
Random variates of given type.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- locarray_like, optional
Location parameter (default=0).
- scalearray_like, optional
Scale parameter (default=1).
- sizeint or tuple of ints, optional
Defining number of random variates (default is 1).
- random_state{None, int,
numpy.random.Generator
, numpy.random.RandomState
}, optionalIf
random_state
is None (ornp.random
), thenumpy.random.RandomState
singleton is used. Ifrandom_state
is an int, a newRandomState
instance is used, seeded withrandom_state
. Ifrandom_state
is already aGenerator
orRandomState
instance, that instance is used.
- rvsndarray or scalar
Random variates of given
size
.
- sf(x, *args, **kwds)¶
Survival function (1 -
cdf
) at x of the given RV.- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- sfarray_like
Survival function evaluated at x
- stats(*args, **kwds)¶
Some statistics of the given RV.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional (continuous RVs only)
scale parameter (default=1)
- momentsstr, optional
composed of letters [‘mvsk’] defining which moments to compute: ‘m’ = mean, ‘v’ = variance, ‘s’ = (Fisher’s) skew, ‘k’ = (Fisher’s) kurtosis. (default is ‘mv’)
- statssequence
of requested moments.
- std(*args, **kwds)¶
Standard deviation of the distribution.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- stdfloat
standard deviation of the distribution
- support(*args, **kwargs)¶
Support of the distribution.
- arg1, arg2, …array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- locarray_like, optional
location parameter, Default is 0.
- scalearray_like, optional
scale parameter, Default is 1.
- a, barray_like
end-points of the distribution’s support.
- var(*args, **kwds)¶
Variance of the distribution.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- varfloat
the variance of the distribution
- class schrodinger.application.matsci.gsas.GSASIIpwd.fcjde_gen(momtype=1, a=None, b=None, xtol=1e-14, badvalue=None, name=None, longname=None, shapes=None, extradoc=None, seed=None)¶
Bases:
scipy.stats._distn_infrastructure.rv_continuous
Finger-Cox-Jephcoat D(2phi,2th) function for S/L = H/L Ref: J. Appl. Cryst. (1994) 27, 892-900.
- Parameters
x – array -1 to 1
t – 2-theta position of peak
s – sum(S/L,H/L); S: sample height, H: detector opening, L: sample to detector opening distance
dx – 2-theta step size in deg
- Returns
for fcj.pdf
T = x*dx+t
s = S/L+H/L
if x < 0:
fcj.pdf = [1/sqrt({cos(T)**2/cos(t)**2}-1) - 1/s]/|cos(T)|
if x >= 0: fcj.pdf = 0
- pdf(x, *args, **kwds)¶
Probability density function at x of the given RV.
- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- pdfndarray
Probability density function evaluated at x
- __init__(momtype=1, a=None, b=None, xtol=1e-14, badvalue=None, name=None, longname=None, shapes=None, extradoc=None, seed=None)¶
- cdf(x, *args, **kwds)¶
Cumulative distribution function of the given RV.
- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- cdfndarray
Cumulative distribution function evaluated at
x
- entropy(*args, **kwds)¶
Differential entropy of the RV.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- locarray_like, optional
Location parameter (default=0).
- scalearray_like, optional (continuous distributions only).
Scale parameter (default=1).
Entropy is defined base
e
:>>> import numpy as np >>> drv = rv_discrete(values=((0, 1), (0.5, 0.5))) >>> np.allclose(drv.entropy(), np.log(2.0)) True
- expect(func=None, args=(), loc=0, scale=1, lb=None, ub=None, conditional=False, **kwds)¶
Calculate expected value of a function with respect to the distribution by numerical integration.
The expected value of a function
f(x)
with respect to a distributiondist
is defined as:ub E[f(x)] = Integral(f(x) * dist.pdf(x)), lb
where
ub
andlb
are arguments andx
has thedist.pdf(x)
distribution. If the boundslb
andub
correspond to the support of the distribution, e.g.[-inf, inf]
in the default case, then the integral is the unrestricted expectation off(x)
. Also, the functionf(x)
may be defined such thatf(x)
is0
outside a finite interval in which case the expectation is calculated within the finite range[lb, ub]
.- funccallable, optional
Function for which integral is calculated. Takes only one argument. The default is the identity mapping f(x) = x.
- argstuple, optional
Shape parameters of the distribution.
- locfloat, optional
Location parameter (default=0).
- scalefloat, optional
Scale parameter (default=1).
- lb, ubscalar, optional
Lower and upper bound for integration. Default is set to the support of the distribution.
- conditionalbool, optional
If True, the integral is corrected by the conditional probability of the integration interval. The return value is the expectation of the function, conditional on being in the given interval. Default is False.
Additional keyword arguments are passed to the integration routine.
- expectfloat
The calculated expected value.
The integration behavior of this function is inherited from
scipy.integrate.quad
. Neither this function norscipy.integrate.quad
can verify whether the integral exists or is finite. For examplecauchy(0).mean()
returnsnp.nan
andcauchy(0).expect()
returns0.0
.Likewise, the accuracy of results is not verified by the function.
scipy.integrate.quad
is typically reliable for integrals that are numerically favorable, but it is not guaranteed to converge to a correct value for all possible intervals and integrands. This function is provided for convenience; for critical applications, check results against other integration methods.The function is not vectorized.
To understand the effect of the bounds of integration consider
>>> from scipy.stats import expon >>> expon(1).expect(lambda x: 1, lb=0.0, ub=2.0) 0.6321205588285578
This is close to
>>> expon(1).cdf(2.0) - expon(1).cdf(0.0) 0.6321205588285577
If
conditional=True
>>> expon(1).expect(lambda x: 1, lb=0.0, ub=2.0, conditional=True) 1.0000000000000002
The slight deviation from 1 is due to numerical integration.
The integrand can be treated as a complex-valued function by passing
complex_func=True
toscipy.integrate.quad
.>>> import numpy as np >>> from scipy.stats import vonmises >>> res = vonmises(loc=2, kappa=1).expect(lambda x: np.exp(1j*x), ... complex_func=True) >>> res (-0.18576377217422957+0.40590124735052263j)
>>> np.angle(res) # location of the (circular) distribution 2.0
- fit(data, *args, **kwds)¶
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.
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) andfloc
andfscale
(for location and scale parameters, respectively).- dataarray_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.- **kwdsfloats, 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:
f0…fn : hold respective shape parameters fixed. Alternatively, shape parameters to fix can be specified by name. For example, if
self.shapes == "a, b"
,fa
andfix_a
are equivalent tof0
, andfb
andfix_b
are equivalent tof1
.floc : hold location parameter fixed to specified value.
fscale : hold scale parameter fixed to specified value.
optimizer : The optimizer to use. The optimizer must take
func
, and starting position as the first two arguments, plusargs
(for extra arguments to pass to the function to be optimized) anddisp=0
to suppress output as keyword arguments.method : The method to use. The default is “MLE” (Maximum Likelihood Estimate); “MM” (Method of Moments) is also available.
- TypeError, ValueError
If an input is invalid
FitError
If fitting fails or the fit produced would be invalid
- parameter_tupletuple 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
).
With
method="MLE"
(default), the fit is computed by minimizing the negative log-likelihood function. A large, finite penalty (rather than infinite negative log-likelihood) is applied for observations beyond the support of the distribution.With
method="MM"
, the fit is computed by minimizing the L2 norm of the relative errors between the first k raw (about zero) data moments and the corresponding distribution moments, where k is the number of non-fixed parameters. More precisely, the objective function is:(((data_moments - dist_moments) / np.maximum(np.abs(data_moments), 1e-8))**2).sum()
where the constant
1e-8
avoids division by zero in case of vanishing data moments. Typically, this error norm can be reduced to zero. Note that the standard method of moments can produce parameters for which some data are outside the support of the fitted distribution; this implementation does nothing to prevent this.For either method, the returned answer is not guaranteed to be globally optimal; it may only be locally optimal, or the optimization may fail altogether. If the data contain any of
np.nan
,np.inf
, or-np.inf
, thefit
method will raise aRuntimeError
.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
andscale
):>>> a1, b1, loc1, scale1 = beta.fit(x)
We can also use some prior knowledge about the dataset: let’s keep
loc
andscale
fixed:>>> a1, b1, loc1, scale1 = beta.fit(x, floc=0, fscale=1) >>> loc1, scale1 (0, 1)
We can also keep shape parameters fixed by using
f
-keywords. To keep the zero-th shape parametera
equal 1, usef0=1
or, equivalently,fa=1
:>>> a1, b1, loc1, scale1 = beta.fit(x, fa=1, floc=0, fscale=1) >>> a1 1
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 (0.92087172783841631, 2.0015750750324668)
- fit_loc_scale(data, *args)¶
Estimate loc and scale parameters from data using 1st and 2nd moments.
- dataarray_like
Data to fit.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- Lhatfloat
Estimated location parameter for the data.
- Shatfloat
Estimated scale parameter for the data.
- freeze(*args, **kwds)¶
Freeze the distribution for the given arguments.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution. Should include all the non-optional arguments, may include
loc
andscale
.
- rv_frozenrv_frozen instance
The frozen distribution.
- interval(confidence=None, *args, **kwds)¶
Confidence interval with equal areas around the median.
Deprecated since version 1.9.0: Parameter
alpha
is replaced by parameterconfidence
to avoid name collisions with the shape parameteralpha
of some distributions. Parameteralpha
will be removed in SciPy 1.11.0.- confidencearray_like of float
Probability that an rv will be drawn from the returned range. Each value should be in the range [0, 1].
- arg1, arg2, …array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- locarray_like, optional
location parameter, Default is 0.
- scalearray_like, optional
scale parameter, Default is 1.
- a, bndarray of float
end-points of range that contain
100 * alpha %
of the rv’s possible values.
This is implemented as
ppf([p_tail, 1-p_tail])
, whereppf
is the inverse cumulative distribution function andp_tail = (1-confidence)/2
. Suppose[c, d]
is the support of a discrete distribution; thenppf([0, 1]) == (c-1, d)
. Therefore, whenconfidence=1
and the distribution is discrete, the left end of the interval will be beyond the support of the distribution. For discrete distributions, the interval will limit the probability in each tail to be less than or equal top_tail
(usually strictly less).
- isf(q, *args, **kwds)¶
Inverse survival function (inverse of
sf
) at q of the given RV.- qarray_like
upper tail probability
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- xndarray or scalar
Quantile corresponding to the upper tail probability q.
- logcdf(x, *args, **kwds)¶
Log of the cumulative distribution function at x of the given RV.
- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- logcdfarray_like
Log of the cumulative distribution function evaluated at x
- logpdf(x, *args, **kwds)¶
Log of the probability density function at x of the given RV.
This uses a more numerically accurate calculation if available.
- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- logpdfarray_like
Log of the probability density function evaluated at x
- logsf(x, *args, **kwds)¶
Log of the survival function of the given RV.
Returns the log of the “survival function,” defined as (1 -
cdf
), evaluated atx
.- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- logsfndarray
Log of the survival function evaluated at
x
.
- mean(*args, **kwds)¶
Mean of the distribution.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- meanfloat
the mean of the distribution
- median(*args, **kwds)¶
Median of the distribution.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
Location parameter, Default is 0.
- scalearray_like, optional
Scale parameter, Default is 1.
- medianfloat
The median of the distribution.
- rv_discrete.ppf
Inverse of the CDF
- moment(order=None, *args, **kwds)¶
non-central moment of distribution of specified order.
Deprecated since version 1.9.0: Parameter
n
is replaced by parameterorder
to avoid name collisions with the shape parametern
of several distributions. Parametern
will be removed in SciPy 1.11.0.- orderint, order >= 1
Order of moment.
- arg1, arg2, arg3,…float
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- nnlf(theta, x)¶
Negative loglikelihood function. Notes —– This is
-sum(log pdf(x, theta), axis=0)
wheretheta
are the parameters (including loc and scale).
- ppf(q, *args, **kwds)¶
Percent point function (inverse of
cdf
) at q of the given RV.- qarray_like
lower tail probability
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- xarray_like
quantile corresponding to the lower tail probability q.
- property random_state¶
Get or set the generator object for generating random variates.
If
random_state
is None (ornp.random
), thenumpy.random.RandomState
singleton is used. Ifrandom_state
is an int, a newRandomState
instance is used, seeded withrandom_state
. Ifrandom_state
is already aGenerator
orRandomState
instance, that instance is used.
- rvs(*args, **kwds)¶
Random variates of given type.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- locarray_like, optional
Location parameter (default=0).
- scalearray_like, optional
Scale parameter (default=1).
- sizeint or tuple of ints, optional
Defining number of random variates (default is 1).
- random_state{None, int,
numpy.random.Generator
, numpy.random.RandomState
}, optionalIf
random_state
is None (ornp.random
), thenumpy.random.RandomState
singleton is used. Ifrandom_state
is an int, a newRandomState
instance is used, seeded withrandom_state
. Ifrandom_state
is already aGenerator
orRandomState
instance, that instance is used.
- rvsndarray or scalar
Random variates of given
size
.
- sf(x, *args, **kwds)¶
Survival function (1 -
cdf
) at x of the given RV.- xarray_like
quantiles
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- sfarray_like
Survival function evaluated at x
- stats(*args, **kwds)¶
Some statistics of the given RV.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional (continuous RVs only)
scale parameter (default=1)
- momentsstr, optional
composed of letters [‘mvsk’] defining which moments to compute: ‘m’ = mean, ‘v’ = variance, ‘s’ = (Fisher’s) skew, ‘k’ = (Fisher’s) kurtosis. (default is ‘mv’)
- statssequence
of requested moments.
- std(*args, **kwds)¶
Standard deviation of the distribution.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- stdfloat
standard deviation of the distribution
- support(*args, **kwargs)¶
Support of the distribution.
- arg1, arg2, …array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information).
- locarray_like, optional
location parameter, Default is 0.
- scalearray_like, optional
scale parameter, Default is 1.
- a, barray_like
end-points of the distribution’s support.
- var(*args, **kwds)¶
Variance of the distribution.
- arg1, arg2, arg3,…array_like
The shape parameter(s) for the distribution (see docstring of the instance object for more information)
- locarray_like, optional
location parameter (default=0)
- scalearray_like, optional
scale parameter (default=1)
- varfloat
the variance of the distribution
- schrodinger.application.matsci.gsas.GSASIIpwd.getWidthsCW(pos, sig, gam, shl)¶
Compute the peak widths used for computing the range of a peak for constant wavelength data. On low-angle side, 50 FWHM are used, on high-angle side 75 are used, low angle side extended for axial divergence (for peaks above 90 deg, these are reversed.)
- schrodinger.application.matsci.gsas.GSASIIpwd.getWidthsTOF(pos, alp, bet, sig, gam)¶
Compute the peak widths used for computing the range of a peak for constant wavelength data. 50 FWHM are used on both sides each extended by exponential coeff.
- schrodinger.application.matsci.gsas.GSASIIpwd.getFWHM(pos, Inst)¶
Compute total FWHM from Thompson, Cox & Hastings (1987) , J. Appl. Cryst. 20, 79-83 via getgamFW(g,s).
- Parameters
pos – float peak position in deg 2-theta or tof in musec
Inst – dict instrument parameters
- Returns float
total FWHM of pseudoVoigt in deg or musec
- schrodinger.application.matsci.gsas.GSASIIpwd.getgamFW(g, s)¶
Compute total FWHM from Thompson, Cox & Hastings (1987), J. Appl. Cryst. 20, 79-83 lambda fxn needs FWHM for both Gaussian & Lorentzian components
- Parameters
g – float Lorentzian gamma = FWHM(L)
s – float Gaussian sig
- Returns float
total FWHM of pseudoVoigt
- schrodinger.application.matsci.gsas.GSASIIpwd.getFCJVoigt(pos, intens, sig, gam, shl, xdata)¶
Compute the Finger-Cox-Jepcoat modified Voigt function for a CW powder peak by direct convolution. This version is not used.
- schrodinger.application.matsci.gsas.GSASIIpwd.getBackground(pfx, parmDict, bakType, dataType, xdata, fixedBkg={})¶
Computes the background from vars pulled from gpx file or tree.
- schrodinger.application.matsci.gsas.GSASIIpwd.getBackgroundDerv(hfx, parmDict, bakType, dataType, xdata)¶
needs a doc string
- schrodinger.application.matsci.gsas.GSASIIpwd.getFCJVoigt3(pos, sig, gam, shl, xdata)¶
Compute the Finger-Cox-Jepcoat modified Pseudo-Voigt function for a CW powder peak in external Fortran routine
- schrodinger.application.matsci.gsas.GSASIIpwd.getdFCJVoigt3(pos, sig, gam, shl, xdata)¶
Compute analytic derivatives the Finger-Cox-Jepcoat modified Pseudo-Voigt function for a CW powder peak
- schrodinger.application.matsci.gsas.GSASIIpwd.getPsVoigt(pos, sig, gam, xdata)¶
needs a doc string
- schrodinger.application.matsci.gsas.GSASIIpwd.getdPsVoigt(pos, sig, gam, xdata)¶
needs a doc string
- schrodinger.application.matsci.gsas.GSASIIpwd.getEpsVoigt(pos, alp, bet, sig, gam, xdata)¶
needs a doc string
- schrodinger.application.matsci.gsas.GSASIIpwd.getdEpsVoigt(pos, alp, bet, sig, gam, xdata)¶
needs a doc string
- schrodinger.application.matsci.gsas.GSASIIpwd.ellipseSize(H, Sij, GB)¶
Implements r=1/sqrt(sum((1/S)*(q.v)^2) per note from Alexander Brady
- schrodinger.application.matsci.gsas.GSASIIpwd.ellipseSizeDerv(H, Sij, GB)¶
needs a doc string
- schrodinger.application.matsci.gsas.GSASIIpwd.getHKLpeak(dmin, SGData, A, Inst=None, nodup=False)¶
Generates allowed by symmetry reflections with d >= dmin NB: GenHKLf & checkMagextc return True for extinct reflections
- Parameters
dmin – minimum d-spacing
SGData – space group data obtained from SpcGroup
A – lattice parameter terms A1-A6
Inst – instrument parameter info
- Returns
HKLs: np.array hkl, etc for allowed reflections
- schrodinger.application.matsci.gsas.GSASIIpwd.getHKLMpeak(dmin, Inst, SGData, SSGData, Vec, maxH, A)¶
needs a doc string
- schrodinger.application.matsci.gsas.GSASIIpwd.getPeakProfile(dataType, parmDict, xdata, varyList, bakType)¶
Computes the profile for a powder pattern
- schrodinger.application.matsci.gsas.GSASIIpwd.getPeakProfileDerv(dataType, parmDict, xdata, varyList, bakType)¶
needs a doc string
- schrodinger.application.matsci.gsas.GSASIIpwd.Dict2Values(parmdict, varylist)¶
Use before call to leastsq to setup list of values for the parameters in parmdict, as selected by key in varylist
- schrodinger.application.matsci.gsas.GSASIIpwd.Values2Dict(parmdict, varylist, values)¶
Use after call to leastsq to update the parameter dictionary with values corresponding to keys in varylist
- schrodinger.application.matsci.gsas.GSASIIpwd.SetBackgroundParms(Background)¶
Loads background parameters into dicts/lists to create varylist & parmdict
- schrodinger.application.matsci.gsas.GSASIIpwd.DoCalibInst(IndexPeaks, Inst)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.DoPeakFit(FitPgm, Peaks, Background, Limits, Inst, Inst2, data, fixback=None, prevVaryList=[], oneCycle=False, controls=None, dlg=None)¶
Called to perform a peak fit, refining the selected items in the peak table as well as selected items in the background.
- Parameters
FitPgm (str) – type of fit to perform. At present this is ignored.
Peaks (list) – a list of peaks. Each peak entry is a list with 8 values: four values followed by a refine flag where the values are: position, intensity, sigma (Gaussian width) and gamma (Lorentzian width). From the Histogram/”Peak List” tree entry, dict item “peaks”
Background (list) – describes the background. List with two items. Item 0 specifies a background model and coefficients. Item 1 is a dict. From the Histogram/Background tree entry.
Limits (list) – min and max x-value to use
Inst (dict) – Instrument parameters
Inst2 (dict) – more Instrument parameters
data (numpy.array) – a 5xn array. data[0] is the x-values, data[1] is the y-values, data[2] are weight values, data[3], [4] and [5] are calc, background and difference intensities, respectively.
fixback (array) – fixed background values
prevVaryList (list) – Used in sequential refinements to override the variable list. Defaults as an empty list.
oneCycle (bool) – True if only one cycle of fitting should be performed
controls (dict) – a dict specifying two values, Ftol = controls[‘min dM/M’] and derivType = controls[‘deriv type’]. If None default values are used.
dlg (wx.Dialog) – A dialog box that is updated with progress from the fit. Defaults to None, which means no updates are done.
- schrodinger.application.matsci.gsas.GSASIIpwd.calcIncident(Iparm, xdata)¶
needs a doc string
- schrodinger.application.matsci.gsas.GSASIIpwd.REFDRefine(Profile, ProfDict, Inst, Limits, Substances, data)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.makeSLDprofile(data, Substances)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.REFDModelFxn(Profile, Inst, Limits, Substances, data)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.abeles(kz, depth, rho, irho=0, sigma=0)¶
Optical matrix form of the reflectivity calculation. O.S. Heavens, Optical Properties of Thin Solid Films
Reflectometry as a function of kz for a set of slabs.
- Parameters
kz – float[n] (1/Ang). Scattering vector, 2pi sin(theta)/lambda. This is \tfrac12 Q_z.
depth – float[m] (Ang). thickness of each layer. The thickness of the incident medium and substrate are ignored.
rho – float[n,k] (1e-6/Ang^2) Real scattering length density for each layer for each kz
irho – float[n,k] (1e-6/Ang^2) Imaginary scattering length density for each layer for each kz Note: absorption cross section mu = 2 irho/lambda for neutrons
sigma – float[m-1] (Ang) interfacial roughness. This is the roughness between a layer and the previous layer. The sigma array should have m-1 entries.
Slabs are ordered with the surface SLD at index 0 and substrate at index -1, or reversed if kz < 0.
- schrodinger.application.matsci.gsas.GSASIIpwd.SmearAbeles(kz, dq, depth, rho, irho=0, sigma=0)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.makeRefdFFT(Limits, Profile)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.GetStackParms(Layers)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.StackSim(Layers, ctrls, scale=0.0, background={}, limits=[], inst={}, profile=[])¶
Simulate powder or selected area diffraction pattern from stacking faults using DIFFaX
- Parameters
Layers (dict) –
dict with following items
{'Laue':'-1','Cell':[False,1.,1.,1.,90.,90.,90,1.], 'Width':[[10.,10.],[False,False]],'Toler':0.01,'AtInfo':{}, 'Layers':[],'Stacking':[],'Transitions':[]}
ctrls (str) – controls string to be written on DIFFaX controls.dif file
scale (float) – scale factor
background (dict) – background parameters
limits (list) – min/max 2-theta to be calculated
inst (dict) – instrument parameters dictionary
profile (list) – powder pattern data
Note that parameters all updated in place
- schrodinger.application.matsci.gsas.GSASIIpwd.SetPWDRscan(inst, limits, profile)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.SetStackingSF(Layers, debug)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.SetStackingClay(Layers, Type)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.SetCellAtoms(Layers)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.SetStackingTrans(Layers, Nlayers)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.CalcStackingPWDR(Layers, scale, background, limits, inst, profile, debug)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.CalcStackingSADP(Layers, debug)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.makePRFfile(data, MEMtype)¶
makes Dysnomia .prf control file from Dysnomia GUI controls
- Parameters
data (dict) – GSAS-II phase data
MEMtype (int) – 1 for neutron data with negative scattering lengths 0 otherwise
- Returns str
name of Dysnomia control file
- schrodinger.application.matsci.gsas.GSASIIpwd.makeMEMfile(data, reflData, MEMtype, DYSNOMIA)¶
make Dysnomia .mem file of reflection data, etc.
- Parameters
data (dict) – GSAS-II phase data
reflData (list) – GSAS-II reflection data
MEMtype (int) – 1 for neutron data with negative scattering lengths 0 otherwise
DYSNOMIA (str) – path to dysnomia.exe
- schrodinger.application.matsci.gsas.GSASIIpwd.MEMupdateReflData(prfName, data, reflData)¶
Update reflection data with new Fosq, phase result from Dysnomia
- Parameters
prfName (str) – phase.mem file name
reflData (list) – GSAS-II reflection data
- schrodinger.application.matsci.gsas.GSASIIpwd.TestData()¶
needs a doc string
- schrodinger.application.matsci.gsas.GSASIIpwd.test0()¶
- schrodinger.application.matsci.gsas.GSASIIpwd.test1()¶
- schrodinger.application.matsci.gsas.GSASIIpwd.test2(name, delt)¶
- schrodinger.application.matsci.gsas.GSASIIpwd.test3(name, delt)¶