diff --git a/persolhs.py b/persolhs.py new file mode 100644 index 0000000000000000000000000000000000000000..4fabac93c70270eb97ba51f2984720f0576e3977 --- /dev/null +++ b/persolhs.py @@ -0,0 +1,32 @@ +import numpy as np +import matplotlib.pyplot as plt + +#makes a Latin Hyper Cube sample +#returns a matrix X of size n by p +#of a LHS of n values on each of p variables +#for each column of X, the n values are randomly +#distributed with one from each interval +#(0,1/n), (1/n,2/n), ..., (1-1/n,1) +#and they are randomly permuted + +#def lhssample(n=10,p=2): + +#ça donne des résultats moyen beau il y a possiblement une histoire de couches de points à rajouter +def lhssample(n,p): + x = np.random.uniform(size=[n,p]) + for i in range(0,p): + x[:,i] = (np.argsort(x[:,i])+0.5)/n + return x + +x = lhssample(10,10) + + +print(x.shape) + + +plt.plot(x[:, 0], x[:, 1], "o") +plt.xlabel("x") +plt.ylabel("y") +plt.grid() +plt.show() +