Dose anyone know how the Confidence interval for the standard deviation is calculated in normfit function in Matlab? I need a python code to calculate such a parameter. In MATLAB, normfit returns 4 parameter, mean, std and Confidence interval of mean (muCI) and Confidence interval of standard deviation (sigmaCI).
[muHat,sigmaHat,muCI,sigmaCI] = normfit(x)
The python code below gives three parameters, muHat, sigmaHat and muCI. But I need the confidence interval of std (sigmaCI) in Python.
def function(data, confidence= 0.95):
a = 1.0 * np.array(data)
n = len(a)
m ,se = np.mean(a), scipy.stats.sem(a)
h = se * scipy.stats.t.ppf((1 + confidence) / 2., n - 1)
sigma = np.std(data, ddof=1)
return m, sigma, [m - h, m + h]