I have a Python code to generate quasi random standard normal numbers using sobol sequences, however some values generated are greater than 1. Hence I must be doing something wrong. Code:
import sobol_seq
def i4_sobol_generate_std_normal(dim_num, n, skip=1):
"""
Generates multivariate standard normal quasi-random variables.
Parameters:
Input, integer dim_num, the spatial dimension.
Input, integer n, the number of points to generate.
Input, integer SKIP, the number of initial points to skip.
Output, real np array of shape (n, dim_num).
"""
sobols = sobol_seq.i4_sobol_generate(dim_num, n, skip)
normals = norm.ppf(sobols)
return normals
NoOfPaths = 8
rand = i4_sobol_generate_std_normal(1, NoOfPaths)
lRand = []
for i in range(len(rand)):
a = rand[i][0]
lRand.append(a)
rand = np.array(lRand)
Output :
Out[34]:
array([ 0. , 0.67448975, -0.67448975, -0.31863936, 1.15034938,
0.31863936, -1.15034938, -0.88714656])
References : Recommendations for Low Discrepancy (e.g. Sobol) quasi-random sequences in Python/SciPy? and https://github.com/naught101/sobol_seq
I want to use the generated values in monte carlo simulations. Any help is appreciated.
Aucun commentaire:
Enregistrer un commentaire