Skip to content
Snippets Groups Projects
Commit dfdabff8 authored by Liam M. Healy's avatar Liam M. Healy
Browse files

Dirichlet PDF functions, vector length should be K, not K-1

For the Dirichlet PDF functions, the vector length should be K, the
first argument, not K-1.  Reported by Nils Bertschinger.

Conflicts:

	random/dirichlet.lisp
parent 50861266
No related branches found
No related tags found
No related merge requests found
;; Dirichlet distribution ;; Dirichlet distribution
;; Liam Healy, Sun Oct 29 2006 ;; Liam Healy, Sun Oct 29 2006
;; Time-stamp: <2010-07-07 14:24:59EDT dirichlet.lisp> ;; Time-stamp: <2011-07-29 12:23:09EDT dirichlet.lisp>
;; ;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy ;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License ;; Distributed under the terms of the GNU General Public License
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
(defmfun dirichlet-pdf (alpha theta) (defmfun dirichlet-pdf (alpha theta)
"gsl_ran_dirichlet_pdf" "gsl_ran_dirichlet_pdf"
(((1- (dim0 alpha)) sizet) (((dim0 alpha) sizet)
((foreign-pointer alpha) :pointer) ((foreign-pointer alpha) :pointer)
;; theta had better be at least as long as alpha, or they'll be trouble ;; theta had better be at least as long as alpha, or they'll be trouble
((foreign-pointer theta) :pointer)) ((foreign-pointer theta) :pointer))
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
(defmfun dirichlet-log-pdf (alpha theta) (defmfun dirichlet-log-pdf (alpha theta)
"gsl_ran_dirichlet_lnpdf" "gsl_ran_dirichlet_lnpdf"
(((1- (dim0 alpha)) sizet) (((dim0 alpha) sizet)
((foreign-pointer alpha) :pointer) ((foreign-pointer alpha) :pointer)
;; theta had better be at least as long as alpha, or they'll be trouble ;; theta had better be at least as long as alpha, or they'll be trouble
((foreign-pointer theta) :pointer)) ((foreign-pointer theta) :pointer))
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
(alpha #m(1.0d0 2.0d0 3.0d0 4.0d0))) (alpha #m(1.0d0 2.0d0 3.0d0 4.0d0)))
(grid:copy-to (sample rng :dirichlet :alpha alpha))))) (grid:copy-to (sample rng :dirichlet :alpha alpha)))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST 1080.0000000000025d0) (list 3.483648000000004d7)
(MULTIPLE-VALUE-LIST (MULTIPLE-VALUE-LIST
(LET ((ALPHA (LET ((ALPHA
(GRID:MAKE-FOREIGN-ARRAY 'DOUBLE-FLOAT :INITIAL-CONTENTS (GRID:MAKE-FOREIGN-ARRAY 'DOUBLE-FLOAT :INITIAL-CONTENTS
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
'(1.0d0 2.0d0 3.0d0 4.0d0)))) '(1.0d0 2.0d0 3.0d0 4.0d0))))
(DIRICHLET-PDF ALPHA THETA)))) (DIRICHLET-PDF ALPHA THETA))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST 6.984716320118268d0) (list 17.366175671549307d0)
(MULTIPLE-VALUE-LIST (MULTIPLE-VALUE-LIST
(LET ((ALPHA (LET ((ALPHA
(GRID:MAKE-FOREIGN-ARRAY 'DOUBLE-FLOAT :INITIAL-CONTENTS (GRID:MAKE-FOREIGN-ARRAY 'DOUBLE-FLOAT :INITIAL-CONTENTS
...@@ -47,4 +47,3 @@ ...@@ -47,4 +47,3 @@
(GRID:MAKE-FOREIGN-ARRAY 'DOUBLE-FLOAT :INITIAL-CONTENTS (GRID:MAKE-FOREIGN-ARRAY 'DOUBLE-FLOAT :INITIAL-CONTENTS
'(1.0d0 2.0d0 3.0d0 4.0d0)))) '(1.0d0 2.0d0 3.0d0 4.0d0))))
(DIRICHLET-LOG-PDF ALPHA THETA))))) (DIRICHLET-LOG-PDF ALPHA THETA)))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment