-
-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
module: bs.randomModule random updatesModule random updates⨠FeatureNew feature requestNew feature request
Description
ποΈ Request Type
Feature
π§© Feature or Module Name
bs.random
π Description
See #286:
To generate a random number in any distribution, I suggest to use a MCMC method such as the well known Metropolis algorithm.
The idea consist in placing a walker randomly in the desired area in wich we want to generate a random number. We then generate randomly a new position for the walker in this area. If the distribution is lower at the new position than at the old one, we accept the move only if a random number between 0 and 1 is lower than the ratio of the distribution at these two positions.
def metropolis(dist, a, b): x = np.random.random() * (b - a) + a N = 10 for _ in range(N): x2 = np.random.random() * (b - a) + a if np.random.random() < dist(x2) / dist(x): x = x2 return x
Metadata
Metadata
Assignees
Labels
module: bs.randomModule random updatesModule random updates⨠FeatureNew feature requestNew feature request
