def estimate_summary_statistics()

in svinfer/summary_statistics/summary_statistics.py [0:0]


    def estimate_summary_statistics(self, bias=True):
        """
        Compute standard mean, sample standard deviation, sample skewness and sample kurtosis
        given the sample moments of the noisy data and the sample size
        """
        mu1, mu2, mu3, mu4 = self.estimate_moments(self.x_moments)
        # get sample average
        average = mu1
        # compute central moments given raw moments
        # formula: https://en.wikipedia.org/wiki/Central_moment
        central_mu2 = mu2 - mu1 ** 2
        central_mu3 = mu3 - 3 * mu1 * mu2 + 2 * mu1 ** 3
        central_mu4 = mu4 - 4 * mu1 * mu3 + 6 * mu1 ** 2 * mu2 - 3 * mu1 ** 4
        # get sample standard deviation
        # warning: this estimation approach cannot guarantee that the sample std is positive.
        if central_mu2 < 0:
            logging.warning("the estimated central moment is negative!")
        # compute standard deviation with df correction
        standard_deviation = np.sqrt(central_mu2 * self.n / (self.n - 1))
        # compute skewness via method of moments
        skewness = central_mu3 / central_mu2 ** 1.5
        if not bias:
            skewness *= np.sqrt((self.n - 1.0) * self.n) / (self.n - 2.0)
        # compute kurtosis via method of moments
        kurtosis = central_mu4 / central_mu2 ** 2
        if not bias:
            kurtosis = 1.0 / (self.n - 2.0) / (self.n - 3.0) * ((self.n ** 2 - 1) * kurtosis - 3.0 * (self.n - 1) ** 2) + 3
        return average, standard_deviation, skewness, kurtosis