Example #1
0
    def prec_ci(self, alpha=0.05, hpd=True, hpd_draws=100000):
        """
        Computes HPD or regular frequentist interval
        """
        from statlib.tools import quantile

        if hpd:
            n, d = self.var_post_params
            prec_post = stats.gamma(n / 2.0, scale=2.0 / d)
            prec_draws = prec_post.rvs(hpd_draws)
            qs = quantile(prec_draws, [alpha / 2, 0.5, 1 - alpha / 2])
            hpd_lower, median, hpd_upper = qs

            return hpd_lower, median, hpd_upper
        else:
            raise NotImplementedError
Example #2
0
    def prec_ci(self, alpha=0.05, hpd=True, hpd_draws=100000):
        """
        Computes HPD or regular frequentist interval
        """
        from statlib.tools import quantile

        if hpd:
            n, d = self.var_post_params
            prec_post = stats.gamma(n / 2., scale=2. / d)
            prec_draws = prec_post.rvs(hpd_draws)
            qs = quantile(prec_draws, [alpha / 2, 0.5, 1 - alpha / 2])
            hpd_lower, median, hpd_upper = qs

            return hpd_lower, median, hpd_upper
        else:
            raise NotImplementedError
Example #3
0
def boot_ci(sample, samples=10000):
    draws = sample(samples)
    return quantile(draws, [0.05, 0.95])