public static System.Random Restore(this NativeRandomState state) { var binaryFormatter = new BinaryFormatter(); using (var temp = new MemoryStream(state.State)) { return((System.Random)binaryFormatter.Deserialize(temp)); } }
/// <summary> /// Set the internal state of the generator from a <see cref="NumPyRandom"/>. /// for use if one has reason to manually (re-)set the internal state of the pseudo-random number generating algorithm. /// </summary> /// <param name="nativeRandomState">The state to restore onto this <see cref="NumPyRandom"/></param> public void set_state(NativeRandomState nativeRandomState) { randomizer = nativeRandomState.Restore(); }
/// <summary> /// Returns a new instance of <see cref="NumPyRandom"/>. /// </summary> public NumPyRandom RandomState(NativeRandomState state) { return(new NumPyRandom(state)); }
internal NumPyRandom(NativeRandomState nativeRandomState) { set_state(nativeRandomState); }
public static Randomizer Restore(this NativeRandomState state) { return(Randomizer.Deserialize(state.State)); }