edu.stanford.math.plex4.utility
public class MathUtility extends java.lang.Object
Constructor and Description |
---|
MathUtility() |
Modifier and Type | Method and Description |
---|---|
static double |
absApproximation(double x,
double M) |
static double |
dotProduct(double[] a,
double[] b) |
static long |
euclideanGcd(long a,
long b) |
static int |
floorLog2(int input)
This function returns the floor of the base-2 logarithm
of the input.
|
static double |
gaussianDensity(double x)
This function evaluates the standard gaussian density
with mean 0 and variance 1.
|
static double |
gaussianDensity(double x,
double mean,
double standardDeviation)
This function evaluates the 1-dimensional gaussian
density function with specified mean and standard deviation.
|
static double |
greatCircleDistance(double[] x,
double[] y)
This function returns the great circle distance between two
points on the unit sphere given their rectangular coordinates.
|
static double |
greatCircleDistance(double latitude1,
double longitude1,
double latitude2,
double longitude2)
This function returns the great circle distance (geodesic distance)
between two points on the unit sphere.
|
static double |
huberPenaltyFunction(double x,
double M)
This function computes the Huber penalty function of an
input.
|
static double |
maxApproximation(double x,
double y,
double M) |
static int |
maxLog2(int input) |
static int |
minLog2(int input) |
static int[] |
modularInverses(int p)
This function returns the multiplicative inverses of the integers
[0, 1, ..., p-1] in mod p arithmetic.
|
static int |
signum(double l) |
static int |
signum(long l) |
public static long euclideanGcd(long a, long b)
public static int signum(long l)
public static int signum(double l)
public static int[] modularInverses(int p)
p
- public static int floorLog2(int input)
input
- the input argumentpublic static int minLog2(int input)
public static int maxLog2(int input)
public static double greatCircleDistance(double latitude1, double longitude1, double latitude2, double longitude2)
latitude1
- the latitude of the first pointlongitude1
- the longitude of the first pointlatitude2
- the latitude of the second pointlongitude2
- the longitude of the second pointpublic static double greatCircleDistance(double[] x, double[] y)
x
- the first pointy
- the second pointpublic static double huberPenaltyFunction(double x, double M)
x
- the value at which to compute the Huber penalty functionM
- the parameter which determines the linear/quadratic regionpublic static double absApproximation(double x, double M)
public static double maxApproximation(double x, double y, double M)
public static double gaussianDensity(double x)
x
- the point to evaluate atpublic static double gaussianDensity(double x, double mean, double standardDeviation)
x
- the point to evaluate atmean
- the mean of the distributionstandardDeviation
- the standard deviation of the distributionpublic static double dotProduct(double[] a, double[] b)