Skip to content

Commit

Permalink
Merge pull request #151 from FlorianPfaff/fix/toroidalvmsine_pdf
Browse files Browse the repository at this point in the history
Fixed pdf for ToroidalVonMisesSineDistribution
  • Loading branch information
FlorianPfaff authored Sep 5, 2023
2 parents f493c7c + 2a062e8 commit 1f1f1c7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ def s(m):
def pdf(self, xs):
assert xs.shape[-1] == 2
p = self.C * np.exp(
self.kappa[0] * np.cos(xs[0] - self.mu[0])
+ self.kappa[1] * np.cos(xs[1] - self.mu[1])
+ self.lambda_ * np.sin(xs[0] - self.mu[0]) * np.sin(xs[1] - self.mu[1])
self.kappa[0] * np.cos(xs[..., 0] - self.mu[0])
+ self.kappa[1] * np.cos(xs[..., 1] - self.mu[1])
+ self.lambda_
* np.sin(xs[..., 0] - self.mu[0])
* np.sin(xs[..., 1] - self.mu[1])
)
return p
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,31 @@ def test_trigonometric_moment_numerical(self):
self.tvm.trigonometric_moment_numerical(0), np.array([1, 1]), decimal=5
)

def _unnormalized_pdf(self, x):
# jscpd:ignore-start
# pylint: disable=R0801
def _unnormalized_pdf(self, xs):
return np.exp(
self.kappa[0] * np.cos(x[0] - self.mu[0])
+ self.kappa[1] * np.cos(x[1] - self.mu[1])
+ self.lambda_ * np.sin(x[0] - self.mu[0]) * np.sin(x[1] - self.mu[1])
self.kappa[0] * np.cos(xs[..., 0] - self.mu[0])
+ self.kappa[1] * np.cos(xs[..., 1] - self.mu[1])
+ self.lambda_
* np.sin(xs[..., 0] - self.mu[0])
* np.sin(xs[..., 1] - self.mu[1])
)

# jscpd:ignore-end

@parameterized.expand(
[
(np.array([3, 2]),),
(np.array([1, 4]),),
(np.array([5, 6]),),
(np.array([-3, 11]),),
(np.array([[5, 1], [6, 3]]),),
(
np.column_stack(
(np.arange(0, 2 * np.pi, 0.1), np.arange(1 * np.pi, 3 * np.pi, 0.1))
),
),
]
)
def test_pdf(self, x):
Expand Down

0 comments on commit 1f1f1c7

Please sign in to comment.