Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bilby
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
lscsoft
bilby
Commits
261adead
There was a problem fetching the pipeline summary.
Commit
261adead
authored
6 years ago
by
Colm Talbot
Browse files
Options
Downloads
Patches
Plain Diff
add truncated gaussian prior
parent
8d4a5772
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
peyote/prior.py
+34
-1
34 additions, 1 deletion
peyote/prior.py
with
34 additions
and
1 deletion
peyote/prior.py
+
34
−
1
View file @
261adead
...
...
@@ -4,7 +4,7 @@ from __future__ import division
import
numpy
as
np
from
scipy.interpolate
import
interp1d
from
scipy.integrate
import
cumtrapz
from
scipy.special
import
erfinv
from
scipy.special
import
erf
,
erfinv
class
Prior
(
object
):
...
...
@@ -224,6 +224,39 @@ class Gaussian(Prior):
return
np
.
exp
(
-
(
self
.
mu
-
val
)
**
2
/
(
2
*
self
.
sigma
**
2
))
/
(
2
*
np
.
pi
)
**
0.5
/
self
.
sigma
class
TruncatedGaussian
(
Prior
):
"""
Truncated Gaussian prior
https://en.wikipedia.org/wiki/Truncated_normal_distribution
"""
def
__init__
(
self
,
mu
,
sigma
,
low
,
high
,
name
=
None
,
latex_label
=
None
):
"""
Power law with bounds and alpha, spectral index
"""
Prior
.
__init__
(
self
,
name
,
latex_label
)
self
.
mu
=
mu
self
.
sigma
=
sigma
self
.
low
=
low
self
.
high
=
high
self
.
normalisation
=
(
erf
((
self
.
high
-
self
.
mu
)
/
2
**
0.5
/
self
.
sigma
)
-
erf
(
(
self
.
low
-
self
.
mu
)
/
2
**
0.5
/
self
.
sigma
))
/
2
def
rescale
(
self
,
val
):
"""
'
Rescale
'
a sample from the unit line element to the appropriate truncated Gaussian prior.
This maps to the inverse CDF. This has been analytically solved for this case.
"""
return
erfinv
(
2
*
val
*
self
.
normalisation
+
erf
(
(
self
.
low
-
self
.
mu
)
/
2
**
0.5
/
self
.
sigma
))
*
2
**
0.5
*
self
.
sigma
+
self
.
mu
def
prob
(
self
,
val
):
"""
Return the prior probability of val
"""
return
np
.
exp
(
-
(
self
.
mu
-
val
)
**
2
/
(
2
*
self
.
sigma
**
2
))
/
(
2
*
np
.
pi
)
**
0.5
/
self
.
sigma
/
self
.
normalisation
class
Interped
(
Prior
):
def
__init__
(
self
,
xx
,
yy
,
name
=
None
,
latex_label
=
None
):
...
...
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