pythonarrayskurtosis

calculate kurtosis for each sequence or intervall in array


I have an array with 1000(rows) values and I want to calculate for every 10 values the kurtosis in the order from the first value zero to 999 of my array. So, in the end, I would have 100 kurtosis values from the list. Then I want to put all the kurtosis values into one list. The variable does not matter, it is just that I am new to Python and do not know much about it. Appreciate all your help.


Solution

  • How about this?

    import numpy as np
    from scipy.stats import kurtosis
    
    a = np.arange((1000)) #replace a with your array
    ks = np.zeros((100))
    
    for i range(100):
       ks[i] = kurtosis(a[i*10:i*10+10])
    

    This will loop through the i's, so that when i = 0, a[i*10:i*10+10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], when i = 1, a[i*10:i*10+10] = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19], etc.

    ks is then a list of 100 kurtosis values.