/// <summary> /// Returns a deep copy of the receiver. /// </summary> /// <returns></returns> public override Object Clone() { WeightedRandomSampler copy = (WeightedRandomSampler)base.Clone(); copy.generator = (Uniform)this.generator.Clone(); return(copy); }
/// <summary> /// /// </summary> /// <param name="weight"></param> /// <param name="size"></param> public static void Test(int weight, int size) { WeightedRandomSampler sampler = new WeightedRandomSampler(); sampler.Weight = weight; IntArrayList sample = new IntArrayList(); for (int i = 0; i < size; i++) { if (sampler.SampleNextElement()) { sample.Add(i); } } Console.WriteLine("Sample = " + sample); }