seems like you didn't use np.random.permutation properly
https://numpy.org/doc/stable/reference/random/generated/numpy.random.permutation.html
This function takes an array or int and then returns ndarray.
Problem is that array is used as an index. I don't think this is normal.
Is kz_StdRnd a function?
Then you should apply that function to the permutation array using map.
kz_StdRnd = list(map(kz_StdRnd, np.random.permutation(n_samples)))
instead of
kz_StdRnd = kz_StdRnd[np.random.permutation(n_samples)]
I mimicked your code and made a few modification to make it runnable without error at least. I am pretty sure the result is not what you intended though.
- I changed ppf function to pdf function in the same module. You might want to look at this page. Seems like there is some issue with ppf function.
https://github.com/scipy/scipy/issues/2888
- I changed 'z' variable in the last code to 'zg'
This is the code:
from scipy.stats import norm
import numpy as np
n_samples=20000
a1 = np.random.uniform(0,1,(n_samples,1))
a10=np.linspace(1,20000, num=n_samples)-1+a1/n_samples
#print(type(a10))
k=1+0.16*norm.pdf(a10,0,1)
p=np.random.permutation(n_samples)
#print("p: ", p)
#print("k: ", k)
k = k[p]
#print("k:", k)
for j in range(n_samples):
a=9.5
zg=274.32
kz=(2.01*(max(4.75,zg)/zg)**(2/a)*k[j])