numpy - Python - Recreate Minitab normal probability plot -


essentially same question asked here, want in python. have used scipy stats probplot, want recreate confidence interval curves , i'm not sure how proceed. can point me in direction??

this i'm at:

status quo

this want be:

minitab probability plot

i have answer first part of task not sure how minitab calculates confidence interval. none of definitions found yield similar. here code base plot , fit:

import numpy np import scipy.stats stats matplotlib import scale mscale matplotlib import transforms mtransforms matplotlib.ticker import formatter, locator   class ppfscale(mscale.scalebase):     name = 'ppf'      def __init__(self, axis, **kwargs):         mscale.scalebase.__init__(self)      def get_transform(self):         return self.ppftransform()      def set_default_locators_and_formatters(self, axis):         class percformatter(formatter):             def __call__(self, x, pos=none):                 # \u00b0 : degree symbol                 return "%d %%" % (x*100)          class ppflocator(locator):             def __call__(self):                 return np.array([1,5,10,20,30,40,50,60,70,80,90,95,99])/100.0          axis.set_major_locator(ppflocator())         axis.set_major_formatter(percformatter())         axis.set_minor_formatter(percformatter())      def limit_range_for_scale(self, vmin, vmax, minpos):         return max(vmin, 1e-6), min(vmax, 1-1e-6)      class ppftransform(mtransforms.transform):         input_dims = 1         output_dims = 1         is_separable = true          def ___init__(self, thresh):             mtransforms.transform.__init__(self)             self.thresh = thresh          def transform_non_affine(self, a):             out = stats.norm.ppf(a)             return out           def inverted(self):             return ppfscale.ippftransform()      class ippftransform(mtransforms.transform):         input_dims = 1         output_dims = 1         is_separable = true          def transform_non_affine(self, a):              return stats.norm.cdf(a)          def inverted(self):             return ppfscale.ppftransform()  mscale.register_scale(ppfscale)   if __name__ == '__main__':     import matplotlib.pyplot plt     statsmodels.tools.tools import ecdf      size = 20      #generate data     pf = stats.norm(loc=9, scale=2.0)     values = pf.rvs(size=size)          values.sort()      #calculate empirical cdf     cumprob = ecdf(values)(values)      #fit data     loc, scale = stats.norm.fit(values)     pffit = stats.norm(loc=loc,scale=scale)      x = np.linspace(values.min(),values.max(),3)     ax = plt.subplot(111)     ax.plot(values,cumprob, 'go', alpha=0.7, markersize=10)     ax.plot(x,pffit.cdf(x),'-',label='mean: {:.2f}'.format(loc))     ax.set_yscale('ppf')     ax.set_ylim(0.01,0.99)     ax.grid(true)     ax.legend(loc=0)     plt.show() 

the nonlinear axis class taken 1 of matplotlib examples. gives following plot: percentile plot


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -