Changeset 75e4319 in sasmodels


Ignore:
Timestamp:
Oct 28, 2017 7:31:28 AM (6 years ago)
Author:
dirk
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
a70959a
Parents:
a5a12ca
Message:

create uniform distribution and docs ticket addresses #764

Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • doc/guide/pd/polydispersity.rst

    ra5a12ca r75e4319  
    4343 
    4444*  *Rectangular Distribution* 
     45*  *Uniform Distribution* 
    4546*  *Gaussian Distribution* 
    4647*  *Lognormal Distribution* 
     
    8384 
    8485    Rectangular distribution. 
     86 
     87Uniform Distribution 
     88^^^^^^^^^^^^^^^^^^^^^^^^ 
     89 
     90The Uniform Distribution is defined as 
     91 
     92    .. math:: 
     93 
     94        f(x) = \frac{1}{\text{Norm}} 
     95        \begin{cases} 
     96          1 & \text{for } |x - \bar x| \leq \sigma \\ 
     97          0 & \text{for } |x - \bar x| > \sigma 
     98        \end{cases} 
     99 
     100    where $\bar x$ is the mean of the distribution, $\sigma$ is the half-width, and 
     101    *Norm* is a normalization factor which is determined during the numerical 
     102    calculation. 
     103 
     104    Note that the polydispersity is given by 
     105 
     106    .. math:: \text{PD} = \sigma / \bar x 
     107 
     108    .. figure:: pd_uniform.jpg 
     109 
     110        Uniform distribution. 
    85111 
    86112.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
  • sasmodels/weights.py

    ra5a12ca r75e4319  
    9797        return x, px 
    9898 
     99class UniformDispersion(Dispersion): 
     100    r""" 
     101    Uniform dispersion, with width $\sigma$. 
     102 
     103    .. math:: 
     104 
     105        w = 1 
     106    """ 
     107    type = "uniform" 
     108    default = dict(npts=35, width=0, nsigmas=1) 
     109    def _weights(self, center, sigma, lb, ub): 
     110        x = self._linspace(center, sigma, lb, ub) 
     111        x = x[np.fabs(x-center) <= np.fabs(sigma)] 
     112        return x, np.ones_like(x) 
    99113 
    100114class RectangleDispersion(Dispersion): 
     
    210224MODELS = OrderedDict((d.type, d) for d in ( 
    211225    RectangleDispersion, 
     226    UniformDispersion, 
    212227    ArrayDispersion, 
    213228    LogNormalDispersion, 
Note: See TracChangeset for help on using the changeset viewer.