jeudi 19 mai 2022

print multiple random permutations

I am trying to do multiple permutations. From code:

# generate random Gaussian values
from numpy.random import seed
from numpy.random import randn
# seed random number generator
seed(1)
# generate some Gaussian values
values = randn(100)
print(values)

But now I would like to generate, for example, 20 permutations (of values). With code:

import numpy as np
import random
from itertools import permutations
result = np.random.permutation(values)
print(result)

I can only observe one permutation (or "manually" get others). I wish I had many permutations (20 or more) and so automatically calculate the Durbin-Watson statistic for each permutation (from values).

from statsmodels.stats.stattools import durbin_watson
sm.stats.durbin_watson(np.random.permutation(values))

How can I do?




Aucun commentaire:

Enregistrer un commentaire