File talk:Normal normal qq.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
import numpy as np
import matplotlib.pyplot as plt
import scipy.special as sp

## The sample size.                                                            
n = 100

## Generate standard normal data.                                              
X = np.random.normal(size=n)

## Convert to order statistics.                                                
X.sort()

## Normal quantiles.                                                           
P = np.arange(1, n+1, dtype=np.float64) / (n+1)
Q = sp.ndtri(P)

plt.clf()
plt.figure(figsize=(4,3.5))
plt.axes([0.15,0.15,0.8,0.8])
plt.grid(True)
plt.plot(Q, X, 'o', mec='black', mfc='grey')
plt.hold(True)
plt.plot([-3,3], [-3,3], '-', color='black')
plt.xlabel("Normal theoretical quantiles", size=14)
plt.ylabel("Normal data quantiles", size=14)
plt.savefig("normal_normal_qq.pdf")
plt.savefig("normal_normal_qq.svg")

Start a discussion about File:Normal normal qq.svg

Start a discussion