public class SmoothUniform
extends java.lang.Object
Math:
let sigmoid shoulder function be f(x), Sw be shoulder width, Bw be base (max-min) width, and h be the bodyHeight of the base.
f(x) = Ax^3 + Bx^2 f'(x) = 3Ax^2 + 2Bx integral f = Ax^4/4 + Bx^3/3
f(Sw) = h integral of f from 0 to Sw = 1 (area under the curve must be 1) f'(Sw) = 0
yields:
| 0 3Sw^2 2Sw | | h | | 0 | | -1 Sw^3 Sw^2 | * | A | = | 0 | | Bw Sw/4 2Sw/3 | | B | | 1 |
therefore:
h = 1 / (Sw + Bw) A = -2 / (Sw^3 * (Sw + Bw)) B = 3 / (Sw^3 * Sw^2*Bw)
Modifier and Type | Method and Description |
---|---|
static DoubleTensor |
dPdf(DoubleTensor xMin,
DoubleTensor xMax,
DoubleTensor shoulderWidth,
DoubleTensor x) |
static DoubleTensor |
pdf(DoubleTensor xMin,
DoubleTensor xMax,
DoubleTensor shoulderWidth,
DoubleTensor x) |
static DoubleTensor |
sample(int[] shape,
DoubleTensor xMin,
DoubleTensor xMax,
double edgeSharpness,
KeanuRandom random)
Will return samples between xMin and xMax as well as samples from the left and right shoulder.
|
public static DoubleTensor sample(int[] shape, DoubleTensor xMin, DoubleTensor xMax, double edgeSharpness, KeanuRandom random)
shape
- result tensor shapexMin
- min value from bodyxMax
- max value from bodyedgeSharpness
- sharpness as a percentage of the body widthrandom
- source of randomnesspublic static DoubleTensor pdf(DoubleTensor xMin, DoubleTensor xMax, DoubleTensor shoulderWidth, DoubleTensor x)
public static DoubleTensor dPdf(DoubleTensor xMin, DoubleTensor xMax, DoubleTensor shoulderWidth, DoubleTensor x)