26. Distribution functions¶
sasmodels.weights
¶
SAS distributions for polydispersity.
-
class
sasmodels.weights.
ArrayDispersion
(npts=None, width=None, nsigmas=None)¶ Bases:
sasmodels.weights.Dispersion
Empirical dispersion curve.
Use
set_weights()
to set \(w = f(x)\).-
get_pars
()¶ Return the parameters to the disperser as a dictionary.
-
get_weights
(center, lb, ub, relative)¶ Return the weights for the distribution.
center is the center of the distribution
lb, ub are the min and max allowed values
relative is True if the distribution width is proportional to the center value instead of absolute. For polydispersity use relative. For orientation parameters use absolute.
-
set_weights
(values, weights)¶ Set the weights for the given x values.
-
default
= {'npts': 35, 'nsigmas': 1, 'width': 0}¶
-
type
= 'array'¶
-
-
class
sasmodels.weights.
Dispersion
(npts=None, width=None, nsigmas=None)¶ Bases:
object
Base dispersion object.
Subclasses should define _weights(center, sigma, lb, ub) which returns the x points and their corresponding weights.
-
get_pars
()¶ Return the parameters to the disperser as a dictionary.
-
get_weights
(center, lb, ub, relative)¶ Return the weights for the distribution.
center is the center of the distribution
lb, ub are the min and max allowed values
relative is True if the distribution width is proportional to the center value instead of absolute. For polydispersity use relative. For orientation parameters use absolute.
-
set_weights
(values, weights)¶ Set the weights on the disperser if it is
ArrayDispersion
.
-
default
= {'npts': 35, 'nsigmas': 3, 'width': 0}¶
-
type
= 'base disperser'¶
-
-
class
sasmodels.weights.
GaussianDispersion
(npts=None, width=None, nsigmas=None)¶ Bases:
sasmodels.weights.Dispersion
Gaussian dispersion, with 1-\(\sigma\) width.
\[w = \exp\left(-\tfrac12 (x - c)^2/\sigma^2\right)\]-
get_pars
()¶ Return the parameters to the disperser as a dictionary.
-
get_weights
(center, lb, ub, relative)¶ Return the weights for the distribution.
center is the center of the distribution
lb, ub are the min and max allowed values
relative is True if the distribution width is proportional to the center value instead of absolute. For polydispersity use relative. For orientation parameters use absolute.
-
set_weights
(values, weights)¶ Set the weights on the disperser if it is
ArrayDispersion
.
-
default
= {'npts': 35, 'nsigmas': 3, 'width': 0}¶
-
type
= 'gaussian'¶
-
-
class
sasmodels.weights.
LogNormalDispersion
(npts=None, width=None, nsigmas=None)¶ Bases:
sasmodels.weights.Dispersion
log Gaussian dispersion, with 1-\(\sigma\) width.
\[w = \frac{\exp\left(-\tfrac12 (\ln x - c)^2/\sigma^2\right)}{x\sigma}\]-
get_pars
()¶ Return the parameters to the disperser as a dictionary.
-
get_weights
(center, lb, ub, relative)¶ Return the weights for the distribution.
center is the center of the distribution
lb, ub are the min and max allowed values
relative is True if the distribution width is proportional to the center value instead of absolute. For polydispersity use relative. For orientation parameters use absolute.
-
set_weights
(values, weights)¶ Set the weights on the disperser if it is
ArrayDispersion
.
-
default
= {'npts': 80, 'nsigmas': 8, 'width': 0}¶
-
type
= 'lognormal'¶
-
-
class
sasmodels.weights.
RectangleDispersion
(npts=None, width=None, nsigmas=None)¶ Bases:
sasmodels.weights.Dispersion
Uniform dispersion, with width \(\sqrt{3}\sigma\).
\[w = 1\]-
get_pars
()¶ Return the parameters to the disperser as a dictionary.
-
get_weights
(center, lb, ub, relative)¶ Return the weights for the distribution.
center is the center of the distribution
lb, ub are the min and max allowed values
relative is True if the distribution width is proportional to the center value instead of absolute. For polydispersity use relative. For orientation parameters use absolute.
-
set_weights
(values, weights)¶ Set the weights on the disperser if it is
ArrayDispersion
.
-
default
= {'npts': 35, 'nsigmas': 1.70325, 'width': 0}¶
-
type
= 'rectangle'¶
-
-
class
sasmodels.weights.
SchulzDispersion
(npts=None, width=None, nsigmas=None)¶ Bases:
sasmodels.weights.Dispersion
Schultz dispersion, with 1-\(\sigma\) width.
\[w = \frac{z^z\,R^{z-1}}{e^{Rz}\,c \Gamma(z)}\]where \(c\) is the center of the distribution, \(R = x/c\) and \(z=(c/\sigma)^2\).
This is evaluated using logarithms as
\[w = \exp\left(z \ln z + (z-1)\ln R - Rz - \ln c - \ln \Gamma(z) \right)\]-
get_pars
()¶ Return the parameters to the disperser as a dictionary.
-
get_weights
(center, lb, ub, relative)¶ Return the weights for the distribution.
center is the center of the distribution
lb, ub are the min and max allowed values
relative is True if the distribution width is proportional to the center value instead of absolute. For polydispersity use relative. For orientation parameters use absolute.
-
set_weights
(values, weights)¶ Set the weights on the disperser if it is
ArrayDispersion
.
-
default
= {'npts': 80, 'nsigmas': 8, 'width': 0}¶
-
type
= 'schulz'¶
-
-
sasmodels.weights.
get_weights
(disperser, n, width, nsigmas, value, limits, relative)¶ Return the set of values and weights for a polydisperse parameter.
disperser is the name of the disperser.
n is the number of points in the weight vector.
width is the width of the disperser distribution.
nsigmas is the number of sigmas to span for the dispersion convolution.
value is the value of the parameter in the model.
limits is [lb, ub], the lower and upper bound on the possible values.
relative is true if width is defined in proportion to the value of the parameter, and false if it is an absolute width.
Returns (value, weight), where value and weight are vectors.
-
sasmodels.weights.
plot_weights
(model_info, pairs)¶ Plot the weights returned by
get_weights()
.model_info is :param model_info: :param pairs: :return: