Returns the variance of a normal distribution truncated at a and b.
Options:
:mean (default 0) mean of untruncated normal distribution
:sd (default 1) standard deviation of untruncated normal distribution
:a (default -infinity) lower truncation point
:b (default +infinity) upper truncation point
Examples:
(use '(incanter core stats))
(truncated-variance :a -1.96 :b 1.96)
(truncated-variance :a 0)
(truncated-variance :b 0)
(use 'incanter.charts)
(def x (range -3 3 0.1))
(def plot (xy-plot x (map #(truncated-variance :a %) x)))
(view plot)
(add-lines plot x (map #(truncated-variance :b %) x))
(def samp (sample-normal 10000))
(add-lines plot x (map #(variance (filter (fn [s] (> s %)) samp)) x))
(add-lines plot x (map #(variance (mult samp (indicator (fn [s] (> s %)) samp))) x))
References:
DeMaris, A. (2004) Regression with social data: modeling continuous and limited response variables.
Wiley-IEEE.
http://en.wikipedia.org/wiki/Truncated_normal_distribution
Comments top
No comments for truncated-variance. Log in to add a comment.