Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NIFTy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Neel Shah
NIFTy
Commits
c0d4c04c
Commit
c0d4c04c
authored
4 years ago
by
Philipp Arras
Browse files
Options
Downloads
Patches
Plain Diff
Add Laplace distribution
parent
9520f5af
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/__init__.py
+2
-1
2 additions, 1 deletion
src/__init__.py
src/library/special_distributions.py
+27
-1
27 additions, 1 deletion
src/library/special_distributions.py
with
29 additions
and
2 deletions
src/__init__.py
+
2
−
1
View file @
c0d4c04c
...
@@ -77,7 +77,8 @@ from .sugar import *
...
@@ -77,7 +77,8 @@ from .sugar import *
from
.plot
import
Plot
from
.plot
import
Plot
from
.library.special_distributions
import
InverseGammaOperator
,
UniformOperator
from
.library.special_distributions
import
(
InverseGammaOperator
,
UniformOperator
,
LaplaceOperator
)
from
.library.los_response
import
LOSResponse
from
.library.los_response
import
LOSResponse
from
.library.dynamic_operator
import
(
dynamic_operator
,
from
.library.dynamic_operator
import
(
dynamic_operator
,
dynamic_lightcone_operator
)
dynamic_lightcone_operator
)
...
...
This diff is collapsed.
Click to expand it.
src/library/special_distributions.py
+
27
−
1
View file @
c0d4c04c
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
import
numpy
as
np
import
numpy
as
np
from
scipy.interpolate
import
CubicSpline
from
scipy.interpolate
import
CubicSpline
from
scipy.stats
import
invgamma
,
norm
from
scipy.stats
import
invgamma
,
norm
,
laplace
from
..
import
random
from
..
import
random
from
..domain_tuple
import
DomainTuple
from
..domain_tuple
import
DomainTuple
...
@@ -158,3 +158,29 @@ class UniformOperator(Operator):
...
@@ -158,3 +158,29 @@ class UniformOperator(Operator):
def
inverse
(
self
,
field
):
def
inverse
(
self
,
field
):
res
=
norm
.
_ppf
(
field
.
val
/
self
.
_scale
-
self
.
_loc
)
res
=
norm
.
_ppf
(
field
.
val
/
self
.
_scale
-
self
.
_loc
)
return
Field
(
field
.
domain
,
res
)
return
Field
(
field
.
domain
,
res
)
def
LaplaceOperator
(
domain
,
alpha
,
delta
=
1e-2
):
"""
Transforms a Gaussian with unit covariance and zero mean into a
Laplacian distribution.
The pdf of the laplace distribution is defined as follows:
.. math::
\\
frac{
\\
alpha}{2}
\\
exp
\\
left(-
\\
alpha |x|
\\
right)
This transformation is implemented as a spline interpolation which maps a
Gaussian onto a Laplace distribution.
Parameters
----------
domain : Domain, tuple of Domain or DomainTuple
The domain on which the field shall be defined. This is at the same
time the domain and the target of the operator.
alpha : float
The alpha-parameter of the Laplace distribution.
delta : float
Distance between sampling points for spline interpolation.
"""
return
_InterpolationOperator
(
domain
,
lambda
x
:
laplace
.
ppf
(
norm
.
_cdf
(
x
),
float
(
alpha
)),
-
8.2
,
8.2
,
delta
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment