Returns the variance of a normal distribution (with mean mu and standard
deviation sigma) with the lower tail censored at 'a' and the upper
tail censored at 'b'
(defn censored-variance-two-sided
" Returns the variance of a normal distribution (with mean mu and standard
deviation sigma) with the lower tail censored at 'a' and the upper
tail censored at 'b'
"
([a b mu sigma]
(let [a-std (psi a mu sigma)
b-std (psi b mu sigma)
sigma-sq (* sigma sigma)
Ey (censored-mean-two-sided a b mu sigma)
cdf-a (cdf-normal a-std)
cdf-b (cdf-normal b-std)]
(+ (* cdf-a (* a a))
(* (- cdf-b cdf-a)
(+ sigma-sq (* mu mu) (* 2 mu sigma (lambda-two-sided a-std b-std))))
(* sigma-sq (- (* a-std (pdf-normal a-std)) (* b-std (pdf-normal b-std))))
(- (* (- 1 cdf-b) (* b b)) (* Ey Ey))))))
Comments top
No comments for censored-variance-two-sided. Log in to add a comment.