/// <summary> /// Returns a deep copy of the receiver. /// </summary> /// <returns></returns> public override Object Clone() { RandomSampler copy = (RandomSampler)base.Clone(); copy.my_RandomGenerator = (RandomEngine)this.my_RandomGenerator.Clone(); return(copy); }
/// <summary> /// Constructs a random sampler that samples <tt>n</tt> random elements from an input sequence of <tt>N</tt> elements. /// </summary> /// <param name="n">the total number of elements to choose (must be >= 0).</param> /// <param name="N">number of elements to choose from (must be >= n).</param> /// <param name="randomGenerator">a random number generator. Set this parameter to <tt>null</tt> to use the default random number generator.</param> public RandomSamplingAssistant(long n, long N, RandomEngine randomGenerator) { this.n = n; this.sampler = new RandomSampler(n, N, 0, randomGenerator); this.buffer = new long[(int)System.Math.Min(n, MAX_BUFFER_SIZE)]; if (n > 0) { this.buffer[0] = -1; // start with the right offset } FetchNextBlock(); }