
Fixed a few limit cases in some distributions (e.g. (uniform-dist 0 0) didn't act like a delta distribution, (beta-dist 0 0) and (beta-dist +inf.0 +inf.0) pretended to be defined by unique limits even though they can't be) Made integer distributions' pdfs return +nan.0 when given non-integers Added "private/statistics/counting.rkt", for hashing and binning samples Added `flvector-sums' (cumulative sums with single rounding error) Added `flinteger?', `flnan?' and `flrational?', which are faster than their non-flonum counterparts (at least in Typed Racket; haven't tested untyped)
24 lines
753 B
Racket
24 lines
753 B
Racket
#lang typed/racket/base
|
|
|
|
(require "../../../flonum.rkt"
|
|
"../../functions/beta.rkt")
|
|
|
|
(provide flbeta-log-pdf)
|
|
|
|
(: flbeta-log-pdf (Flonum Flonum Flonum -> Flonum))
|
|
(define (flbeta-log-pdf a b x)
|
|
(cond [(or (a . fl< . 0.0) (b . fl< . 0.0)
|
|
(and (fl= a 0.0) (fl= b 0.0))
|
|
(and (fl= a +inf.0) (fl= b +inf.0)))
|
|
+nan.0]
|
|
[(or (fl= a 0.0) (fl= b +inf.0))
|
|
(if (fl= x 0.0) +inf.0 -inf.0)]
|
|
[(or (fl= b 0.0) (fl= a +inf.0))
|
|
(if (fl= x 1.0) +inf.0 -inf.0)]
|
|
[(or (x . fl< . 0.0) (x . fl> . 1.0))
|
|
-inf.0]
|
|
[else
|
|
(flsum (list (fl* (fl- a 1.0) (fllog x))
|
|
(fl* (fl- b 1.0) (fllog1p (- x)))
|
|
(- (fllog-beta a b))))]))
|