类 MathUtils
- java.lang.Object
-
- net.quanter.shield.utils.maths.MathUtils
-
public class MathUtils extends Object
数字工具类- 从以下版本开始:
- 1.3.12.RELEASE
- 作者:
- 王老实
-
-
构造器概要
构造器 构造器 说明 MathUtils()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static doubleavg(double[] a)求平均函数static doubleceil(double x, double d)向上取整static intceil(int x, int d)向上取证static int[]fibonacci(int m, int a0, int a1)根据数组个数计算斐波拉起数列static double[]fibonacciPersent(int m, int a0, int a1)根据数组个数计算斐波拉起数列 普通版,斐波拉起数列是 1 1 2 3 5 8...static doublefloor(double x, double d)向下取整static intfloor(int x, int d)向下取整static doublegaussian(double u)正太分布函数static double[]getMaxMin(double... d)求最大最小值函数static intgetRandom(int max)返回不大于参数的随机数static doublemax(double... d)求最大值函数static doublemin(double... d)求最小值函数static doubleround(double x, int size)四舍五入取,返回最后指定长度static doublestd(double[] a)求标准差函数,标准差公式 ⒈方差s^2=[(x1-x)^2+(x2-x)^2+......static doublesum(double[] a)求和函数
-
-
-
方法详细资料
-
getMaxMin
public static final double[] getMaxMin(double... d)
求最大最小值函数- 参数:
d- 数组- 返回:
- [0]:最大值 [1]:最小值
-
max
public static final double max(double... d)
求最大值函数- 参数:
d- 数组- 返回:
- 最大值
-
min
public static final double min(double... d)
求最小值函数- 参数:
d- 数组- 返回:
- 最小值
-
sum
public static final double sum(double[] a)
求和函数- 参数:
a- 求和的数组- 返回:
- 和
-
avg
public static final double avg(double[] a)
求平均函数- 参数:
a- 求平均的数组- 返回:
- 平均数
-
std
public static final double std(double[] a)
求标准差函数,标准差公式 ⒈方差s^2=[(x1-x)^2+(x2-x)^2+......(xn-x)^2]/(n) (x为平均数) ⒉标准差=方差的算术平方根- 参数:
a- 求标准差的数组- 返回:
- 标准差
-
getRandom
public static final int getRandom(int max)
返回不大于参数的随机数- 参数:
max- 随机数最大数- 返回:
- 随机数
-
gaussian
public static double gaussian(double u)
正太分布函数- 参数:
u- 正态分布数- 返回:
- 正态分布
-
fibonacciPersent
public static double[] fibonacciPersent(int m, int a0, int a1)根据数组个数计算斐波拉起数列 普通版,斐波拉起数列是 1 1 2 3 5 8...- 参数:
m- 数组个数a0- 第一个元素大小a1- 第二个元素大小- 返回:
- 斐波拉契数列
-
fibonacci
public static int[] fibonacci(int m, int a0, int a1)根据数组个数计算斐波拉起数列- 参数:
m- 数组个数a0- 第一个元素大小a1- 第二个元素大小- 返回:
- 斐波拉契数列
-
round
public static double round(double x, int size)四舍五入取,返回最后指定长度- 参数:
x- [1213.5556 1.431232]size- 6- 返回:
- [1213.56 1.43123]
-
floor
public static double floor(double x, double d)向下取整- 参数:
x- 原始数 [31.2,43.8]d- 精度 0.5- 返回:
- [31, 43.5]
-
ceil
public static double ceil(double x, double d)向上取整- 参数:
x- 原始数 [31.2,43.8]d- 精度 0.5- 返回:
- [31.5, 44]
-
floor
public static int floor(int x, int d)向下取整- 参数:
x- 原始数 [31,143]d- 精度 100- 返回:
- [0, 100]
-
ceil
public static int ceil(int x, int d)向上取证- 参数:
x- [21,178]d- 100- 返回:
- [100, 200]
-
-