File: laplace.py

package info (click to toggle)
sasmodels 1.0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 16,488 kB
  • sloc: python: 26,277; ansic: 8,036; makefile: 150; sh: 63
file content (20 lines) | stat: -rw-r--r-- 465 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import numpy as np
from scipy.stats import laplace

from sasmodels import weights

class Dispersion(weights.Dispersion):
    r"""
    Laplace distribution

    .. math::

        w(x) = e^{-\sigma |x - \mu|}
    """
    type = "laplace"
    default = dict(npts=35, width=0, nsigmas=3)  # default values
    def _weights(self, center, sigma, lb, ub):
        x = self._linspace(center, sigma, lb, ub)
        wx = laplace.pdf(x, center, sigma)
        return x, wx