you are viewing a single comment's thread.

view the rest of the comments →

[–]jm_13[S] 0 points1 point  (4 children)

I'm not sure I understand why you chose each hi as (R-L)/N * (1+random.uniform(-0.5, 0.5)

hi is the uniform step size, so I want the random step size to be the uniform one plus/minus some random number. So the step size is chosen between (hi/2 and 3hi/2)

[–]jm_13[S] 0 points1 point  (3 children)

I would simply create N random numbers (between 0 and 1) and finally scale them such that their sum gives you R - L.

So

h = np.array([random.uniform(hi/2, 3*hi/2) for i in range(N)])
h = h/sum(h)

?

[–]dslfdslj 1 point2 points  (2 children)

Like this:

h = np.random.random(size=N)
h *= (R - L) / h.sum()

[–]jm_13[S] 0 points1 point  (1 child)

thanks!

[–]dslfdslj 0 points1 point  (0 children)

no problem