File talk:Normal exponential 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 exponential data.                                         
X = -np.log(np.random.uniform(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.ylim(ymin=-0.2)
plt.xlabel("Normal theoretical quantiles", size=14)
plt.ylabel("Exponential data quantiles", size=14)
plt.savefig("normal_exponential_qq.pdf")
plt.savefig("normal_exponential_qq.svg")

Start a discussion about File:Normal exponential qq.svg

Start a discussion