censored-mean-lower
function
Usage: (censored-mean-lower a mu sigma)
Returns the mean of a normal distribution (with mean mu and standard
deviation sigma) with the lower tail censored at 'a'
Source
censored-mean-two-sided
function
Usage: (censored-mean-two-sided a b mu sigma)
Returns the mean 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'
Source
censored-mean-upper
function
Usage: (censored-mean-upper b mu sigma)
Returns the mean of a normal distribution (with mean mu and standard
deviation sigma) with the upper tail censored at 'b'
Source
censored-variance-lower
function
Usage: (censored-variance-lower a mu sigma)
Returns the variance of a normal distribution (with mean mu and standard
deviation sigma) with the lower tail censored at 'a'
Source
censored-variance-two-sided
function
Usage: (censored-variance-two-sided a b mu sigma)
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'
Source
censored-variance-upper
function
Usage: (censored-variance-upper b mu sigma)
Returns the variance of a normal distribution (with mean mu and standard
deviation sigma) with the upper tail censored at 'b'
Source
truncated-variance
function
Usage: (truncated-variance & {:keys [mean sd a b], :or {mean 0, sd 1, a NEGATIVE_INFINITY, b POSITIVE_INFINITY}})
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
Source