001 /* 002 * Created on Aug 6, 2005 003 * 004 */ 005 package aima.util; 006 007 /** 008 * @author Ravi Mohan 009 * 010 */ 011 012 import aima.probability.JavaRandomizer; 013 import aima.probability.Randomizer; 014 015 public class RangeRandomizer implements Randomizer { 016 017 private double lower; 018 019 private double upper; 020 021 private JavaRandomizer random; 022 023 public RangeRandomizer(double lower, double upper) { 024 this.lower = lower; 025 this.upper = upper; 026 this.random = new JavaRandomizer(); 027 } 028 029 public double nextDouble() { 030 double ran = random.nextDouble(); 031 double scaled_ran = ran * (upper - lower); 032 return lower + scaled_ran; 033 } 034 035 }