|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.softsynth.jmsl.Limits
public class Limits
Handy class for handling ranges between a low and a high value.
Limits have a low and high value, and clip method.
Random walk is implemented here as well.
Example:
// take a random walk of 400 steps Limits randomWalk = new Limits(10, 50, 1); // low, high, range for (int i=0; i<400; i++) { System.out.print((int)randomWalk.getValue() + " "); randomWalk.randomStep(); }
Constructor Summary | |
---|---|
Limits(double l,
double h)
Limits (low, high) |
|
Limits(double l,
double h,
double r)
Limits(low, high, randomStepRange |
Method Summary | |
---|---|
double |
clip(double val)
|
static double |
clipTo(double val,
double lo,
double hi)
return value clipped to specified range - static version, don't need an instance of Limits() to use this |
static int |
clipTo(int val,
int lo,
int hi)
return value clipped to specified range - static version, don't need an instance of Limits() to use this |
double |
getHigh()
upper bound |
int |
getIntValue()
return the current value of random walk |
double |
getLow()
lower bound |
double |
getRange()
returns range for a random step. |
double |
getValue()
return the current value of random walk |
static void |
main(java.lang.String[] args)
Take a random walk |
double |
randomStep()
Take one step in a random walk, adding a random value betwwen -range .. |
void |
setLimits(double l,
double h)
set the bounds |
void |
setRange(double r)
set how high up or down the value can change with each random step |
void |
setValue(double value)
set current value of random walk |
java.lang.String |
toString()
|
boolean |
within(double value)
Returns true if val is between this.getLow() and this.getHigh(), inclusive |
static boolean |
within(double val,
double lo,
double hi)
Returns true if val is between lo and hi, inclusive |
boolean |
within(int value)
Returns true if val is between this.getLow() and this.getHigh(), inclusive |
static boolean |
within(int val,
int lo,
int hi)
Returns true if val is between lo and hi, inclusive |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Limits(double l, double h)
public Limits(double l, double h, double r)
Method Detail |
---|
public double randomStep()
public double getValue()
public int getIntValue()
public void setValue(double value)
public double getRange()
public void setRange(double r)
public double getLow()
public double getHigh()
public void setLimits(double l, double h)
public java.lang.String toString()
toString
in class java.lang.Object
public double clip(double val)
public static double clipTo(double val, double lo, double hi)
public static int clipTo(int val, int lo, int hi)
public static boolean within(double val, double lo, double hi)
public static boolean within(int val, int lo, int hi)
public boolean within(double value)
public boolean within(int value)
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |