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
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
;; Dirichlet distribution
;; 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
;; Distributed under the terms of the GNU General Public License
@@ -54,7 +54,7 @@

(defmfun dirichlet-pdf (alpha theta)
  "gsl_ran_dirichlet_pdf"
  (((1- (dim0 alpha)) sizet)
  (((dim0 alpha) sizet)
   ((foreign-pointer alpha) :pointer)
   ;; theta had better be at least as long as alpha, or they'll be trouble
   ((foreign-pointer theta) :pointer))
@@ -67,7 +67,7 @@

(defmfun dirichlet-log-pdf (alpha theta)
  "gsl_ran_dirichlet_lnpdf"
  (((1- (dim0 alpha)) sizet)
  (((dim0 alpha) sizet)
   ((foreign-pointer alpha) :pointer)
   ;; theta had better be at least as long as alpha, or they'll be trouble
   ((foreign-pointer theta) :pointer))
+2 −3
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@
	  (alpha #m(1.0d0 2.0d0 3.0d0 4.0d0)))
      (grid:copy-to (sample rng :dirichlet :alpha alpha)))))
  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
   (LIST 1080.0000000000025d0)
   (list 3.483648000000004d7)
   (MULTIPLE-VALUE-LIST
    (LET ((ALPHA
	   (GRID:MAKE-FOREIGN-ARRAY 'DOUBLE-FLOAT :INITIAL-CONTENTS
@@ -38,7 +38,7 @@
			'(1.0d0 2.0d0 3.0d0 4.0d0))))
      (DIRICHLET-PDF ALPHA THETA))))
  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
   (LIST 6.984716320118268d0)
   (list 17.366175671549307d0)
   (MULTIPLE-VALUE-LIST
    (LET ((ALPHA
	   (GRID:MAKE-FOREIGN-ARRAY 'DOUBLE-FLOAT :INITIAL-CONTENTS
@@ -47,4 +47,3 @@
	   (GRID:MAKE-FOREIGN-ARRAY 'DOUBLE-FLOAT :INITIAL-CONTENTS
			'(1.0d0 2.0d0 3.0d0 4.0d0))))
      (DIRICHLET-LOG-PDF ALPHA THETA)))))