You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All MDA tools employing random numbers should provide a consistent interface allowing to assign a seed for the employed pseudo-random number generator (PRNG) or even a PRNG state. If possible, numpy's random module should be used by default. This has already been proposed by @kain88-de in PR #1932.
A good example for how this could be done nicely already exists in the initializer of the class MDAnalysis.analysis.encore.clustering.ClusteringMethod.KMeans:
Here, the kwarg random_state accepts either an int serving as a seed or a numpy.random.RandomState object. By default, the global numpy PRNG state is used.
Actual behaviour
The way random numbers are handled in MDA varies widely, and implementation range from good examples as the above one to rather "ugly" ones such as in the C-level part of the MDAnalysis.analysis.encore.dimensionality_reduction.stochasticproxembed extension:
lib/src/transformations/transformations.c (will be tricky)
To the best of my knowledge, providing access to numpy's global PRNG at the C-level is not easily possible. Unless we find a good way of exposing numpy.random.mtrand to the C-level, we'll have to port (at least parts of) the MDA C-level code to Cython.
Possible caveats:
Performance
Thread safety
Current version of MDAnalysis:
0.18.1-dev
The text was updated successfully, but these errors were encountered:
zemanj
changed the title
Provide consistent PRNG interface for all MDA tools using random numbers
Provide consistent PRNG interface for all MDA tools that use random numbers
Jun 12, 2018
Related to MDAnalysis/mdaencore#37 - I think... at least if one starts working on analysis.encore's random number handling then they should take the discussion in MDAnalysis/mdaencore#37 into account.
Expected behaviour
All MDA tools employing random numbers should provide a consistent interface allowing to assign a seed for the employed pseudo-random number generator (PRNG) or even a PRNG state. If possible, numpy's
random
module should be used by default. This has already been proposed by @kain88-de in PR #1932.A good example for how this could be done nicely already exists in the initializer of the class
MDAnalysis.analysis.encore.clustering.ClusteringMethod.KMeans
:Here, the kwarg
random_state
accepts either anint
serving as a seed or anumpy.random.RandomState
object. By default, the global numpy PRNG state is used.Actual behaviour
The way random numbers are handled in MDA varies widely, and implementation range from good examples as the above one to rather "ugly" ones such as in the C-level part of the
MDAnalysis.analysis.encore.dimensionality_reduction.stochasticproxembed
extension:Here, the random number quality is poor, and reproducing previous results is virtually impossible.
Affected parts of the MDA code:
At the Python level:
At the C level:
To the best of my knowledge, providing access to numpy's global PRNG at the C-level is not easily possible. Unless we find a good way of exposing
numpy.random.mtrand
to the C-level, we'll have to port (at least parts of) the MDA C-level code to Cython.Possible caveats:
Current version of MDAnalysis:
0.18.1-dev
The text was updated successfully, but these errors were encountered: