Skip to content

Commit

Permalink
Setting xmin and xmax as property for AlignedSpin
Browse files Browse the repository at this point in the history
  • Loading branch information
tsunhopang authored Feb 4, 2024
1 parent 0edc0fe commit 397b2e3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/jimgw/prior.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,6 @@ class AlignedSpin(Prior):
"""

amax: Float = 0.99
xmax: Float = 0.99
xmin: Float = -0.99
chi_axis: Array = field(default_factory=lambda: jnp.linspace(0, 1, num=1000))
cdf_vals: Array = field(default_factory=lambda: jnp.linspace(0, 1, num=1000))

Expand All @@ -310,15 +308,21 @@ def __init__(
super().__init__(naming, transforms)
assert self.n_dim == 1, "Alignedspin needs to be 1D distributions"
self.amax = amax
self.xmax = amax
self.xmin = -amax

# build the interpolation table for the ppf of the one-sided distribution
chi_axis = jnp.linspace(1e-31, self.amax, num=1000)
cdf_vals = -chi_axis * (jnp.log(chi_axis / self.amax) - 1.0) / self.amax
self.chi_axis = chi_axis
self.cdf_vals = cdf_vals

@property
def xmin(self):
return -self.amax

@property
def xmax(self):
return self.amax

def sample(
self, rng_key: PRNGKeyArray, n_samples: int
) -> dict[str, Float[Array, " n_samples"]]:
Expand Down

0 comments on commit 397b2e3

Please sign in to comment.