net.lenkaspace.creeper.helpers
Class CRMaths

java.lang.Object
  extended by net.lenkaspace.creeper.helpers.CRMaths

public class CRMaths
extends java.lang.Object

Provides static methods with mathematical functions

Version:
2.0
Author:
Lenka Pitonakova contact@lenkaspace.net

Constructor Summary
CRMaths()
           
 
Method Summary
static double computeBrokenLine(double middle, double in)
          computeBrokenLine - line with a break middle, x range 0;1 y range -1;1 - an example graph for threshold = 0.2: 1 / / / / 0 / 1 / / / / -1
static double computeLinearBeforeThreshold(double in, double threshold)
          computeLinearBeforeThreshold - for x=<0;1>, y=<0;1>.
static double computeLinearInverseBeforeThreshold(double in, double threshold)
          computeInverseBeforeThreshold - for x=<0;1>, y=<0;1>.
static double computeLinearNegativeInverseBeforeThreshold(double in, double threshold)
          computeLinearNegativeInverseBeforeThreshold - for x=<0;1>, y=<-1;0>.
static double computeNegativeHillBeforeThreshold(double in, double threshold)
          computeNegativeHillBeforeThreshold - extension of computeLinearNegativeInverseBeforeThreshold, for x=<-1;1>, y=<-1;1> - an example graph for threshold = 0.2: -0.2 0.2 -1 ________ 0 _________ 1 | | | | \ / \ / \ / \ / -1
static double computeNegativeValleyBeforeThreshold(double in, double threshold)
          computeNegativeValleyBeforeThreshold - extension of computeLinearNegativeInverseBeforeThreshold, for range in = <-1;1> - an example graph for threshold = 0.2: -0.2 0.2 -1 ____0____ 1 | | | | / \ / \ / \ / \ / \ / \ -1
static double computeSigmoid(double in)
          computeSigmoid - returns sigmoid from <0;1> value for x=<0;1>
static double computeSigmoidWithParams(double in, double slope, double xAxisThreshold)
          computeSigmoid - returns a value from <-1;1> for x=<-1;1> based on two sigmoid with half of the Y range.
static double computeStepFunctionFirstPositive(double in, double threshold)
          computeStepFunctionFirstPositive - for x=<0;1>, y=<-1;1>.
static double computeVShapeImbalanced(double in, double middle, double maxLeft, double maxRight)
          computeVshape - returns value from <-1;1> based on a v-shaped graph for x=<0;1> - example: middle = 0.3, maxLeft = 0.4, maxRIght = 0.8 1 / / \ / \ / 0 \ 0.3 / 1 \ / \ / \ / \ / -1 \/
static java.lang.String formatDouble(double number_, int numOfdecimalPoints_)
          Format a double to return format X.YYYY, where the number of Y's is the number of decimal points
static double getDistanceOfPoints(double x1_, double y1_, double x2_, double y2_)
          Get distance between points in a 2D space
static double getRandomDouble(boolean inclZero_)
          Return a random double between 0 and 1, including or excluding 0
static double getRandomGaussian(double mean_, double variance_)
          Return a random Gaussian number
static int getRandomInteger(int start_, int end_)
          Return a random integer between
static int getRandomInteger(int start_, int end_, boolean canBePositiveOrNegative_)
          Return a random integer between
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CRMaths

public CRMaths()
Method Detail

getDistanceOfPoints

public static double getDistanceOfPoints(double x1_,
                                         double y1_,
                                         double x2_,
                                         double y2_)
Get distance between points in a 2D space


formatDouble

public static java.lang.String formatDouble(double number_,
                                            int numOfdecimalPoints_)
Format a double to return format X.YYYY, where the number of Y's is the number of decimal points

Parameters:
number_ - double number to format
numOfdecimalPoints_ - int number of decimal points
Returns:
String formatted string

getRandomDouble

public static double getRandomDouble(boolean inclZero_)
Return a random double between 0 and 1, including or excluding 0

Parameters:
inclZero_ - boolean is true, 0 can also be a result

getRandomInteger

public static int getRandomInteger(int start_,
                                   int end_)
Return a random integer between

Parameters:
start_ - int start of the interval, included
end_ - int end of the interval, included

getRandomInteger

public static int getRandomInteger(int start_,
                                   int end_,
                                   boolean canBePositiveOrNegative_)
Return a random integer between

Parameters:
start_ - int start of the interval, included
end_ - int end of the interval, included
canBePositiveOrNegative_ - the function can also return numbers from <-end;-start>

getRandomGaussian

public static double getRandomGaussian(double mean_,
                                       double variance_)
Return a random Gaussian number


computeBrokenLine

public static double computeBrokenLine(double middle,
                                       double in)
computeBrokenLine - line with a break middle, x range 0;1 y range -1;1 - an example graph for threshold = 0.2: 1 / / / / 0 / 1 / / / / -1


computeVShapeImbalanced

public static double computeVShapeImbalanced(double in,
                                             double middle,
                                             double maxLeft,
                                             double maxRight)
computeVshape - returns value from <-1;1> based on a v-shaped graph for x=<0;1> - example: middle = 0.3, maxLeft = 0.4, maxRIght = 0.8 1 / / \ / \ / 0 \ 0.3 / 1 \ / \ / \ / \ / -1 \/


computeSigmoid

public static double computeSigmoid(double in)
computeSigmoid - returns sigmoid from <0;1> value for x=<0;1>


computeSigmoidWithParams

public static double computeSigmoidWithParams(double in,
                                              double slope,
                                              double xAxisThreshold)
computeSigmoid - returns a value from <-1;1> for x=<-1;1> based on two sigmoid with half of the Y range. The sigmoids mirrored along the Y-axis


computeLinearBeforeThreshold

public static double computeLinearBeforeThreshold(double in,
                                                  double threshold)
computeLinearBeforeThreshold - for x=<0;1>, y=<0;1>. An example graph for threshold = 0.5: 1 ________ | | / / / 0 0.5 1


computeLinearInverseBeforeThreshold

public static double computeLinearInverseBeforeThreshold(double in,
                                                         double threshold)
computeInverseBeforeThreshold - for x=<0;1>, y=<0;1>. An example graph for threshold = 0.5: 1 \ \ \ | | |________ 0 0.5 1


computeLinearNegativeInverseBeforeThreshold

public static double computeLinearNegativeInverseBeforeThreshold(double in,
                                                                 double threshold)
computeLinearNegativeInverseBeforeThreshold - for x=<0;1>, y=<-1;0>. An example graph for threshold = 0.5: 0 _________ 1 | | / / / / -1/


computeNegativeHillBeforeThreshold

public static double computeNegativeHillBeforeThreshold(double in,
                                                        double threshold)
computeNegativeHillBeforeThreshold - extension of computeLinearNegativeInverseBeforeThreshold, for x=<-1;1>, y=<-1;1> - an example graph for threshold = 0.2: -0.2 0.2 -1 ________ 0 _________ 1 | | | | \ / \ / \ / \ / -1


computeNegativeValleyBeforeThreshold

public static double computeNegativeValleyBeforeThreshold(double in,
                                                          double threshold)
computeNegativeValleyBeforeThreshold - extension of computeLinearNegativeInverseBeforeThreshold, for range in = <-1;1> - an example graph for threshold = 0.2: -0.2 0.2 -1 ____0____ 1 | | | | / \ / \ / \ / \ / \ / \ -1


computeStepFunctionFirstPositive

public static double computeStepFunctionFirstPositive(double in,
                                                      double threshold)
computeStepFunctionFirstPositive - for x=<0;1>, y=<-1;1>. An example graph for threshold = 0.4: 1 _______ | | 0 |0.4 1 | |__________ -1