-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
103dbfb
commit 0b0b6bc
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
test/inferenceql/inference/gpm/primitive_gpms/poisson_test.cljc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(ns inferenceql.inference.gpm.primitive-gpms.poisson-test | ||
(:require [clojure.math :as math] | ||
[clojure.test :as test :refer [deftest is]] | ||
[inferenceql.inference.gpm :as gpm] | ||
[inferenceql.inference.gpm.primitive-gpms.poisson :as poisson] | ||
[inferenceql.inference.gpm.proto :as gpm.proto] | ||
[inferenceql.inference.utils :as utils])) | ||
|
||
(def var-name "poisson") | ||
|
||
(def poisson-pgpm | ||
(let [suff-stats {:n 0 :sum-x 0 :sum-log-fact 0} | ||
hypers {:a 2 :b 2}] | ||
(poisson/spec->poisson var-name :suff-stats suff-stats :hyperparameters hypers))) | ||
|
||
(deftest logpdf | ||
(let [targets {"poisson" 0} | ||
constraints {"poisson" 1}] | ||
(is (= 1.0 (math/exp (gpm.proto/logpdf poisson-pgpm {} {})))) | ||
(is (= 1.0 (math/exp (gpm.proto/logpdf poisson-pgpm targets targets)))) | ||
(is (= ##-Inf (gpm.proto/logpdf poisson-pgpm targets constraints)))) | ||
(is (utils/almost-equal? -1.2163953243244932 (gpm.proto/logpdf poisson-pgpm {"poisson" 1} {}) utils/relerr 1E-8))) |