Search code examples
pythonstatisticsnormal-distribution

How to calculate Rankits with Python?


How can I calculate Rankits with Python?

https://en.wikipedia.org/wiki/Rankit

In particular I want to reproduce the example on Wikipedia: So I search for a function which takes a list [16, 22, 40, 43, 65, 75] and then returns the corresponding rankits: [−1.2672, −0.6418, −0.2016, 0.2016, 0.6418, 1.2672]


Solution

  • observation = [16, 22, 40, 43, 65, 75]
    import numpy as np
    import scipy.stats
    def Q_Q_Prob(data):
        n = len(data)
        prob_level = []
        
        for i in range(1,n+1):
            prob_level.append(np.round((i-0.5)/n,5))
        Standard_normal_quantiles = scipy.stats.norm.ppf(prob_level)
        return Standard_normal_quantiles
    
    print(Q_Q_Prob(observation))
    

    This gives exact result for the example in book name : Applied Multivariate Statistical Analysis (RICHARD A. JOHNSON)see the example, However not giving exact values for the mentioned example. Sharing this because this might give you a idea.