          prior-location :location} prior]
     (t-distribution (* 2 prior-shape)
                     prior-location
-                    (/ (* prior-scale (+ 1 prior-lambda))
-                       (* prior-lambda prior-shape)))))
+                    (sqrt (/ (* prior-scale (+ 1 prior-lambda))
+                             (* prior-lambda prior-shape))))))
 
 (comment 
 (sample (marginal (normal :mu :s2) (normal-inverse-gamma 2 3 1 2)))

(def s22 1)
(def prior-mean 3)
(def prior-lambda 2)
(def prior-shape 5)
(def prior-scale 3)
(- (log-pdf (posterior Y (normal :mu :s2) (normal-inverse-gamma prior-mean prior-lambda prior-shape prior-scale)) [mu1 s21])
   (log-pdf (posterior Y (normal :mu :s2) (normal-inverse-gamma  prior-mean prior-lambda prior-shape prior-scale)) [mu2 s22]) )


(defrecord NormalInverseGamma [location lambda shape scale]
  random
  (sample [d] (let [s2 (sample (inverse-gamma shape scale))
                    mu (sample (normal location (/ s2 lambda)))]
                [mu s2]))
  (sample [d n] (take n (repeatedly #(sample d))))
  probability-function
