Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Lightweight Bartering Grid
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## lbg.common.math
Class CommonMath

    java.lang.Object
      lbg.common.math.CommonMath

    public abstract class CommonMath

extends java.lang.Object

Author:
  Cyril Briquet

Constructor Summary
`CommonMath()`

Method Summary
`static java.lang.String` | `div_label_2dd(double a)`
`static java.lang.String` | `div_label_2dd(double a, double b)`
`static java.lang.String` | `div_label_2dd(double a, double b, double factor)`
`static java.lang.String` | `div_label_2dd(long a)`
`static java.lang.String` | `div_label_2dd(long a, long b)`
`static java.lang.String` | `div_label_2dd(long a, long b, double factor)`
`static java.lang.String` | `div_label(double a)`
`static java.lang.String` | `div_label(double a, double b)`
`static java.lang.String` | `div_label(double a, double b, double factor)`
`static java.lang.String` | `div_label(long a)`
`static java.lang.String` | `div_label(long a, long b)`
`static java.lang.String` | `div_label(long a, long b, double factor)`
`static double` | `filterToZeroIfNaN(double d)` Filters target double-precision floating point number to zero if its value is not a number, else leaves it unchanged.
`static int` | `generateHashCode(int target)` Returns a hash code for given number.
`static int` | `generateHashCode(int target_principal, int target_secondary)` Returns a hash code for given pair of numbers.
`static int` | `generateHashCode(long target)` Returns a hash code for given number.
`static int` | `generateHashCode(java.lang.String target)` Returns a hash code for given String.
`static double` | `mean(double x1, double x2)` Computes the mean of the two taget values.
`static double` | `normalizeCheckedValue(double base_val, double max_val)` Normalizes target base value with respect to target maximum value.
`static double` | `normalizeValue(double base_val, double max_val)` Normalizes target base value with respect to target maximum value.
`static boolean` | `sampleRandomBoolean()` Returns a random boolean.
`static int` | `sampleRandomFileSize(java.lang.String filename)` Samples a random file size sampled from a random distribution for target filename.
`static int` | `sampleUniformDist()` Samples a uniform distribution.
`static int` | `sampleUniformDist(int lo, int hi)` Samples a uniform distribution.
`static long` | `sampleUniformDist(long lo, long hi)` Samples a uniform distribution.
`static float` | `sampleUniformDistWithinUnity()` Samples a uniform distribution.
`static void` | `setSeed(long seed)`
`static double` | `stddev(double sum_x, double sum_squared_x, long N)` Deprecated.
`static double` | `uncheckedStddev(double sum_x, double sum_squared_x, long N)` Deprecated.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### CommonMath

    public CommonMath()

Method Detail

### sampleUniformDist

    public static int sampleUniformDist(int lo,
                                        int hi)
                                 throws GridException

  Samples a uniform distribution. The returned number belongs to the target range.

  Parameters:
    `lo` - low boundary
    `hi` - high boundary
  Returns:
    random int number belonging to [lo..hi]
  Throws:
    `GridException`

### sampleUniformDist

    public static long sampleUniformDist(long lo,
                                         long hi)
                                  throws GridException

  Samples a uniform distribution. The returned number belongs to the target range.

  Parameters:
    `lo` - low boundary
    `hi` - high boundary
  Returns:
    random int number belonging to [lo..hi]
  Throws:
    `GridException`

### sampleUniformDist

    public static int sampleUniformDist()
                                 throws GridException

  Samples a uniform distribution. The returned number may be any int value.

  Returns:
    random int number
  Throws:
    `GridException`

### sampleUniformDistWithinUnity

    public static float sampleUniformDistWithinUnity()
                                              throws GridException

  Samples a uniform distribution. The returned number belongs to the interval [0.0f..1.0f].

  Returns:
    random float number belonging to [0.0f..1.0f]
  Throws:
    `GridException`

### sampleRandomFileSize

    public static int sampleRandomFileSize(java.lang.String filename)
                                    throws GridException

  Samples a random file size sampled from a random distribution for target filename.

  Returned values are guaranteed to be in the interval [2 << 10..2 << 22 + 2 << 10]

  Different calls with the same target filename are guaranteed to result in the same file size.

  Parameters:
    `filename` - targer filename
  Returns:
    random file size
  Throws:
    `GridException` - if target filename is illegal

### sampleRandomBoolean

    public static boolean sampleRandomBoolean()

  Returns a random boolean.

  Returns:
    random boolean

### div_label

    public static java.lang.String div_label(long a)

### div_label

    public static java.lang.String div_label(long a,
                                             long b)

### div_label

    public static java.lang.String div_label(double a)

### div_label

    public static java.lang.String div_label(double a,
                                             double b)

### div_label

    public static java.lang.String div_label(long a,
                                             long b,
                                             double factor)

### div_label

    public static java.lang.String div_label(double a,
                                             double b,
                                             double factor)

### div_label_2dd

    public static java.lang.String div_label_2dd(long a)

### div_label_2dd

    public static java.lang.String div_label_2dd(long a,
                                                 long b)

### div_label_2dd

    public static java.lang.String div_label_2dd(long a,
                                                 long b,
                                                 double factor)

### div_label_2dd

    public static java.lang.String div_label_2dd(double a)

### div_label_2dd

    public static java.lang.String div_label_2dd(double a,
                                                 double b)

### div_label_2dd

    public static java.lang.String div_label_2dd(double a,
                                                 double b,
                                                 double factor)

### mean

    public static double mean(double x1,
                              double x2)

  Computes the mean of the two taget values.

  Returns:
    mean of the two target values

### stddev

    @Deprecated
    public static double stddev(double sum_x,
                                           double sum_squared_x,
                                           long N)
                         throws GridException

  Deprecated.

  Computes the standard deviation of N observations, given their sum (i.e. sum of the x_i) and squared sum (i.e. sum of the (x_i)^2).

  Parameters:
    `sum_x` - sum of the observations
    `sum_squared_x` - sum of the squared observations
    `N` - number of observations
  Returns:
    standard deviation of the observations
  Throws:
    `GridException` - if a parameter is illegal

### uncheckedStddev

    @Deprecated
    public static double uncheckedStddev(double sum_x,
                                                    double sum_squared_x,
                                                    long N)

  Deprecated.

  Computes the standard deviation of N observations, given their sum (i.e. sum of the x_i) and squared sum (i.e. sum of the (x_i)^2).

  Note that this implementation does not throw an Exception, but instead returns a conventional, illegal value.

  Parameters:
    `sum_x` - sum of the observations
    `sum_squared_x` - sum of the squared observations
    `N` - number of observations
  Returns:
    standard deviation of the observations, -1.0 if a parameter is illegal

### filterToZeroIfNaN

    public static final double filterToZeroIfNaN(double d)

  Filters target double-precision floating point number to zero if its value is not a number, else leaves it unchanged.

  Parameters:
    `d` - target double-precision floating point number
  Returns:
    target number itself, or zero if target number is not a number

### normalizeValue

    public static double normalizeValue(double base_val,
                                        double max_val)
                                 throws GridException

  Normalizes target base value with respect to target maximum value.

  Note: target base value greater than target maximum value are considered equal to target maximum value.

  Parameters:
    `base_val` - target base value
    `max_val` - target maximum value
  Returns:
    normalized (i.e. included in [0.0..1.0]) target base value
  Throws:
    `GridException` - if a parameter is illegal

### normalizeCheckedValue

    public static double normalizeCheckedValue(double base_val,
                                               double max_val)
                                        throws GridException

  Normalizes target base value with respect to target maximum value.

  Parameters:
    `base_val` - target base value
    `max_val` - target maximum value
  Returns:
    normalized (i.e. included in [0.0..1.0]) target base value
  Throws:
    `GridException` - if target base value is greater than target maximum value, or if a parameter is illegal

### generateHashCode

    public static int generateHashCode(int target)

  Returns a hash code for given number.

  The hash code is guaranteed to be different from Integer.MIN_VALUE, which can facilitate caching and lazy initilization of hash codes.

  Parameters:
    `target` - target number
  Returns:
    hash code

### generateHashCode

    public static int generateHashCode(long target)

  Returns a hash code for given number.

  The hash code is guaranteed to be different from Integer.MIN_VALUE, which can facilitate caching and lazy initilization of hash codes.

  Parameters:
    `target` - target number
  Returns:
    hash code

### generateHashCode

    public static int generateHashCode(java.lang.String target)

  Returns a hash code for given String.

  The hash code is guaranteed to be different from Integer.MIN_VALUE, which can facilitate caching and lazy initilization of hash codes.

  Parameters:
    `target` - target String
  Returns:
    hash code

### generateHashCode

    public static int generateHashCode(int target_principal,
                                       int target_secondary)

  Returns a hash code for given pair of numbers.

  The hash code is guaranteed to be different from Integer.MIN_VALUE, which can facilitate caching and lazy initilization of hash codes.

  Parameters:
    `target_principal` - target number
    `target_secondary` - target number
  Returns:
    hash code

### setSeed

    public static void setSeed(long seed)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Lightweight Bartering Grid
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

> Copyright (c) 2005-2008, Cyril Briquet, parts Xavier Dalem.