Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
PTAInterpretation
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
CI / CD
CI / CD
Pipelines
Schedules
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Hannah Middleton
PTAInterpretation
Commits
d5731d8a
Commit
d5731d8a
authored
Jun 08, 2023
by
Hannah Middleton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
agn model with cpnest
parent
598572ac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
0 deletions
+76
-0
run_agn_cpnest.py
models/agnostic_model/run_agn_cpnest.py
+76
-0
mergerratemodel.py
models/galaxy_model/mergerratemodel.py
+0
-0
No files found.
models/agnostic_model/run_agn_cpnest.py
0 → 100644
View file @
d5731d8a
import
numpy
as
np
import
cpnest.model
from
scipy.stats
import
gaussian_kde
as
kde
import
matplotlib.pyplot
as
plt
import
hmodel
def
readChain
():
'''
read in the chains
'''
samples
=
np
.
genfromtxt
(
'../../chains/dr2new_crn_fixed/chains_h.txt'
)
return
samples
def
makeKDE
():
'''
make the KDEs to use in the likelihood
'''
samples
=
readChain
()
KDE
=
kde
(
samples
)
return
KDE
def
priorBounds
():
logno
=
[
-
20.0
,
3.0
]
beta
=
[
-
2.0
,
7.0
]
gamma
=
[
0.2
,
5.0
]
alpha
=
[
-
3.0
,
3.0
]
delta
=
[
-
1.0
,
2.0
]
priors
=
[
logno
,
beta
,
gamma
,
alpha
,
delta
]
return
priors
class
kdeModel
(
cpnest
.
model
.
Model
):
# parameter names and get flat prior bounds
names
=
[
'logn'
,
'beta'
,
'gamma'
,
'alpha'
,
'delta'
]
bounds
=
priorBounds
()
def
log_likelihood
(
self
,
param
):
# integration limits
MlowIntLimit
=
10.0
**
6.0
MhighIntLimit
=
10.0
**
11.0
zlowIntLimit
=
0.0
zhighIntLimit
=
5.0
# calculate h
theta
=
param
[
'logn'
],
param
[
'beta'
],
param
[
'gamma'
],
param
[
'alpha'
],
param
[
'delta'
]
hc
=
hmodel
.
hmodel
(
theta
,
\
MlowIntLimit
,
MhighIntLimit
,
\
zlowIntLimit
,
zhighIntLimit
)
log10hModel
=
np
.
log10
(
float
(
hc
))
log_like
=
-
kdeLike
.
logpdf
(
log10hModel
)
return
log_like
kdeLike
=
makeKDE
()
mymodel
=
kdeModel
()
nest
=
cpnest
.
CPNest
(
mymodel
,
maxmcmc
=
1000
,
nlive
=
10000
,
verbose
=
3
)
nest
.
run
()
cpnest
.
CPNest
.
get_posterior_samples
(
nest
)
models/galaxy_model/mergerrate.py
→
models/galaxy_model/mergerrate
model
.py
View file @
d5731d8a
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment