Namechange: Exponential -> Power
This commit is contained in:
parent
344c989cb5
commit
9430653b7a
|
@ -32,13 +32,13 @@ import {
|
||||||
Constructors_algebraicDivide,
|
Constructors_algebraicDivide,
|
||||||
Constructors_algebraicSubtract,
|
Constructors_algebraicSubtract,
|
||||||
Constructors_algebraicLogarithm,
|
Constructors_algebraicLogarithm,
|
||||||
Constructors_algebraicExponentiate,
|
Constructors_algebraicPower,
|
||||||
Constructors_pointwiseAdd,
|
Constructors_pointwiseAdd,
|
||||||
Constructors_pointwiseMultiply,
|
Constructors_pointwiseMultiply,
|
||||||
Constructors_pointwiseDivide,
|
Constructors_pointwiseDivide,
|
||||||
Constructors_pointwiseSubtract,
|
Constructors_pointwiseSubtract,
|
||||||
Constructors_pointwiseLogarithm,
|
Constructors_pointwiseLogarithm,
|
||||||
Constructors_pointwiseExponentiate,
|
Constructors_pointwisePower,
|
||||||
} from "../rescript/Distributions/DistributionOperation/DistributionOperation.gen";
|
} from "../rescript/Distributions/DistributionOperation/DistributionOperation.gen";
|
||||||
|
|
||||||
export let defaultSamplingInputs: SamplingInputs = {
|
export let defaultSamplingInputs: SamplingInputs = {
|
||||||
|
@ -179,9 +179,9 @@ export class GenericDist {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
algebraicExponentiate(d2: GenericDist) {
|
algebraicPower(d2: GenericDist) {
|
||||||
return this.mapResultDist(
|
return this.mapResultDist(
|
||||||
Constructors_algebraicExponentiate({ env: this.env }, this.t, d2.t)
|
Constructors_algebraicPower({ env: this.env }, this.t, d2.t)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,9 +215,9 @@ export class GenericDist {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pointwiseExponentiate(d2: GenericDist) {
|
pointwisePower(d2: GenericDist) {
|
||||||
return this.mapResultDist(
|
return this.mapResultDist(
|
||||||
Constructors_pointwiseExponentiate({ env: this.env }, this.t, d2.t)
|
Constructors_pointwisePower({ env: this.env }, this.t, d2.t)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,8 +213,8 @@ module Constructors = {
|
||||||
C.algebraicSubtract(dist1, dist2)->run(~env)->toDistR
|
C.algebraicSubtract(dist1, dist2)->run(~env)->toDistR
|
||||||
let algebraicLogarithm = (~env, dist1, dist2) =>
|
let algebraicLogarithm = (~env, dist1, dist2) =>
|
||||||
C.algebraicLogarithm(dist1, dist2)->run(~env)->toDistR
|
C.algebraicLogarithm(dist1, dist2)->run(~env)->toDistR
|
||||||
let algebraicExponentiate = (~env, dist1, dist2) =>
|
let algebraicPower = (~env, dist1, dist2) =>
|
||||||
C.algebraicExponentiate(dist1, dist2)->run(~env)->toDistR
|
C.algebraicPower(dist1, dist2)->run(~env)->toDistR
|
||||||
let pointwiseAdd = (~env, dist1, dist2) => C.pointwiseAdd(dist1, dist2)->run(~env)->toDistR
|
let pointwiseAdd = (~env, dist1, dist2) => C.pointwiseAdd(dist1, dist2)->run(~env)->toDistR
|
||||||
let pointwiseMultiply = (~env, dist1, dist2) =>
|
let pointwiseMultiply = (~env, dist1, dist2) =>
|
||||||
C.pointwiseMultiply(dist1, dist2)->run(~env)->toDistR
|
C.pointwiseMultiply(dist1, dist2)->run(~env)->toDistR
|
||||||
|
@ -223,6 +223,6 @@ module Constructors = {
|
||||||
C.pointwiseSubtract(dist1, dist2)->run(~env)->toDistR
|
C.pointwiseSubtract(dist1, dist2)->run(~env)->toDistR
|
||||||
let pointwiseLogarithm = (~env, dist1, dist2) =>
|
let pointwiseLogarithm = (~env, dist1, dist2) =>
|
||||||
C.pointwiseLogarithm(dist1, dist2)->run(~env)->toDistR
|
C.pointwiseLogarithm(dist1, dist2)->run(~env)->toDistR
|
||||||
let pointwiseExponentiate = (~env, dist1, dist2) =>
|
let pointwisePower = (~env, dist1, dist2) =>
|
||||||
C.pointwiseExponentiate(dist1, dist2)->run(~env)->toDistR
|
C.pointwisePower(dist1, dist2)->run(~env)->toDistR
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ module Constructors: {
|
||||||
@genType
|
@genType
|
||||||
let algebraicLogarithm: (~env: env, genericDist, genericDist) => result<genericDist, error>
|
let algebraicLogarithm: (~env: env, genericDist, genericDist) => result<genericDist, error>
|
||||||
@genType
|
@genType
|
||||||
let algebraicExponentiate: (~env: env, genericDist, genericDist) => result<genericDist, error>
|
let algebraicPower: (~env: env, genericDist, genericDist) => result<genericDist, error>
|
||||||
@genType
|
@genType
|
||||||
let pointwiseAdd: (~env: env, genericDist, genericDist) => result<genericDist, error>
|
let pointwiseAdd: (~env: env, genericDist, genericDist) => result<genericDist, error>
|
||||||
@genType
|
@genType
|
||||||
|
@ -91,5 +91,5 @@ module Constructors: {
|
||||||
@genType
|
@genType
|
||||||
let pointwiseLogarithm: (~env: env, genericDist, genericDist) => result<genericDist, error>
|
let pointwiseLogarithm: (~env: env, genericDist, genericDist) => result<genericDist, error>
|
||||||
@genType
|
@genType
|
||||||
let pointwiseExponentiate: (~env: env, genericDist, genericDist) => result<genericDist, error>
|
let pointwisePower: (~env: env, genericDist, genericDist) => result<genericDist, error>
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ module Operation = {
|
||||||
| #Multiply
|
| #Multiply
|
||||||
| #Subtract
|
| #Subtract
|
||||||
| #Divide
|
| #Divide
|
||||||
| #Exponentiate
|
| #Power
|
||||||
| #Logarithm
|
| #Logarithm
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ module Operation = {
|
||||||
| #Add => \"+."
|
| #Add => \"+."
|
||||||
| #Multiply => \"*."
|
| #Multiply => \"*."
|
||||||
| #Subtract => \"-."
|
| #Subtract => \"-."
|
||||||
| #Exponentiate => \"**"
|
| #Power => \"**"
|
||||||
| #Divide => \"/."
|
| #Divide => \"/."
|
||||||
| #Logarithm => (a, b) => log(a) /. log(b)
|
| #Logarithm => (a, b) => log(a) /. log(b)
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,7 +247,7 @@ let pointwiseCombinationFloat = (
|
||||||
): result<t, error> => {
|
): result<t, error> => {
|
||||||
let m = switch arithmeticOperation {
|
let m = switch arithmeticOperation {
|
||||||
| #Add | #Subtract => Error(GenericDist_Types.DistributionVerticalShiftIsInvalid)
|
| #Add | #Subtract => Error(GenericDist_Types.DistributionVerticalShiftIsInvalid)
|
||||||
| (#Multiply | #Divide | #Exponentiate | #Logarithm) as arithmeticOperation =>
|
| (#Multiply | #Divide | #Power | #Logarithm) as arithmeticOperation =>
|
||||||
toPointSetFn(t)->E.R2.fmap(t => {
|
toPointSetFn(t)->E.R2.fmap(t => {
|
||||||
//TODO: Move to PointSet codebase
|
//TODO: Move to PointSet codebase
|
||||||
let fn = (secondary, main) => Operation.Scale.toFn(arithmeticOperation, main, secondary)
|
let fn = (secondary, main) => Operation.Scale.toFn(arithmeticOperation, main, secondary)
|
||||||
|
|
|
@ -20,7 +20,7 @@ module Operation = {
|
||||||
| #Multiply
|
| #Multiply
|
||||||
| #Subtract
|
| #Subtract
|
||||||
| #Divide
|
| #Divide
|
||||||
| #Exponentiate
|
| #Power
|
||||||
| #Logarithm
|
| #Logarithm
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ module Operation = {
|
||||||
| #Add => \"+."
|
| #Add => \"+."
|
||||||
| #Multiply => \"*."
|
| #Multiply => \"*."
|
||||||
| #Subtract => \"-."
|
| #Subtract => \"-."
|
||||||
| #Exponentiate => \"**"
|
| #Power => \"**"
|
||||||
| #Divide => \"/."
|
| #Divide => \"/."
|
||||||
| #Logarithm => (a, b) => log(a) /. log(b)
|
| #Logarithm => (a, b) => log(a) /. log(b)
|
||||||
}
|
}
|
||||||
|
@ -143,8 +143,8 @@ module Constructors = {
|
||||||
ToDistCombination(Algebraic, #Logarithm, #Dist(dist2)),
|
ToDistCombination(Algebraic, #Logarithm, #Dist(dist2)),
|
||||||
dist1,
|
dist1,
|
||||||
)
|
)
|
||||||
let algebraicExponentiate = (dist1, dist2): t => FromDist(
|
let algebraicPower = (dist1, dist2): t => FromDist(
|
||||||
ToDistCombination(Algebraic, #Exponentiate, #Dist(dist2)),
|
ToDistCombination(Algebraic, #Power, #Dist(dist2)),
|
||||||
dist1,
|
dist1,
|
||||||
)
|
)
|
||||||
let pointwiseAdd = (dist1, dist2): t => FromDist(
|
let pointwiseAdd = (dist1, dist2): t => FromDist(
|
||||||
|
@ -167,8 +167,8 @@ module Constructors = {
|
||||||
ToDistCombination(Pointwise, #Logarithm, #Dist(dist2)),
|
ToDistCombination(Pointwise, #Logarithm, #Dist(dist2)),
|
||||||
dist1,
|
dist1,
|
||||||
)
|
)
|
||||||
let pointwiseExponentiate = (dist1, dist2): t => FromDist(
|
let pointwisePower = (dist1, dist2): t => FromDist(
|
||||||
ToDistCombination(Pointwise, #Exponentiate, #Dist(dist2)),
|
ToDistCombination(Pointwise, #Power, #Dist(dist2)),
|
||||||
dist1,
|
dist1,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ let combineShapesContinuousContinuous = (
|
||||||
| #Subtract => (m1, m2) => m1 -. m2
|
| #Subtract => (m1, m2) => m1 -. m2
|
||||||
| #Multiply => (m1, m2) => m1 *. m2
|
| #Multiply => (m1, m2) => m1 *. m2
|
||||||
| #Divide => (m1, mInv2) => m1 *. mInv2
|
| #Divide => (m1, mInv2) => m1 *. mInv2
|
||||||
| #Exponentiate => (m1, mInv2) => m1 ** mInv2
|
| #Power => (m1, mInv2) => m1 ** mInv2
|
||||||
| #Logarithm => (m1, m2) => log(m1) /. log(m2)
|
| #Logarithm => (m1, m2) => log(m1) /. log(m2)
|
||||||
} // note: here, mInv2 = mean(1 / t2) ~= 1 / mean(t2)
|
} // note: here, mInv2 = mean(1 / t2) ~= 1 / mean(t2)
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ let combineShapesContinuousContinuous = (
|
||||||
| #Add => (v1, v2, _, _) => v1 +. v2
|
| #Add => (v1, v2, _, _) => v1 +. v2
|
||||||
| #Subtract => (v1, v2, _, _) => v1 +. v2
|
| #Subtract => (v1, v2, _, _) => v1 +. v2
|
||||||
| #Multiply => (v1, v2, m1, m2) => v1 *. v2 +. v1 *. m2 ** 2. +. v2 *. m1 ** 2.
|
| #Multiply => (v1, v2, m1, m2) => v1 *. v2 +. v1 *. m2 ** 2. +. v2 *. m1 ** 2.
|
||||||
| #Exponentiate => (v1, v2, m1, m2) => v1 *. v2 +. v1 *. m2 ** 2. +. v2 *. m1 ** 2.
|
| #Power => (v1, v2, m1, m2) => v1 *. v2 +. v1 *. m2 ** 2. +. v2 *. m1 ** 2.
|
||||||
| #Logarithm => (v1, v2, m1, m2) => v1 *. v2 +. v1 *. m2 ** 2. +. v2 *. m1 ** 2.
|
| #Logarithm => (v1, v2, m1, m2) => v1 *. v2 +. v1 *. m2 ** 2. +. v2 *. m1 ** 2.
|
||||||
| #Divide => (v1, vInv2, m1, mInv2) => v1 *. vInv2 +. v1 *. mInv2 ** 2. +. vInv2 *. m1 ** 2.
|
| #Divide => (v1, vInv2, m1, mInv2) => v1 *. vInv2 +. v1 *. mInv2 ** 2. +. vInv2 *. m1 ** 2.
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@ let combineShapesContinuousDiscrete = (
|
||||||
()
|
()
|
||||||
}
|
}
|
||||||
| #Multiply
|
| #Multiply
|
||||||
| #Exponentiate
|
| #Power
|
||||||
| #Logarithm
|
| #Logarithm
|
||||||
| #Divide =>
|
| #Divide =>
|
||||||
for j in 0 to t2n - 1 {
|
for j in 0 to t2n - 1 {
|
||||||
|
|
|
@ -118,7 +118,7 @@ module PointwiseCombination = {
|
||||||
switch pointwiseOp {
|
switch pointwiseOp {
|
||||||
| #Add => pointwiseAdd(evaluationParams, t1, t2)
|
| #Add => pointwiseAdd(evaluationParams, t1, t2)
|
||||||
| #Multiply => pointwiseCombine(\"*.", evaluationParams, t1, t2)
|
| #Multiply => pointwiseCombine(\"*.", evaluationParams, t1, t2)
|
||||||
| #Exponentiate => pointwiseCombine(\"**", evaluationParams, t1, t2)
|
| #Power => pointwiseCombine(\"**", evaluationParams, t1, t2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ let all = [
|
||||||
},
|
},
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
makeRenderedDistFloat("scaleExp", (dist, float) => verticalScaling(#Exponentiate, dist, float)),
|
makeRenderedDistFloat("scaleExp", (dist, float) => verticalScaling(#Power, dist, float)),
|
||||||
makeRenderedDistFloat("scaleMultiply", (dist, float) => verticalScaling(#Multiply, dist, float)),
|
makeRenderedDistFloat("scaleMultiply", (dist, float) => verticalScaling(#Multiply, dist, float)),
|
||||||
makeRenderedDistFloat("scaleLog", (dist, float) => verticalScaling(#Logarithm, dist, float)),
|
makeRenderedDistFloat("scaleLog", (dist, float) => verticalScaling(#Logarithm, dist, float)),
|
||||||
Multimodal._function,
|
Multimodal._function,
|
||||||
|
|
|
@ -144,11 +144,11 @@ module MathAdtToDistDst = {
|
||||||
| ("subtract", _) => Error("Subtraction needs two operands")
|
| ("subtract", _) => Error("Subtraction needs two operands")
|
||||||
| ("multiply", [l, r]) => toOkAlgebraic((#Multiply, l, r))
|
| ("multiply", [l, r]) => toOkAlgebraic((#Multiply, l, r))
|
||||||
| ("multiply", _) => Error("Multiplication needs two operands")
|
| ("multiply", _) => Error("Multiplication needs two operands")
|
||||||
| ("pow", [l, r]) => toOkAlgebraic((#Exponentiate, l, r))
|
| ("pow", [l, r]) => toOkAlgebraic((#Power, l, r))
|
||||||
| ("pow", _) => Error("Exponentiation needs two operands")
|
| ("pow", _) => Error("Exponentiation needs two operands")
|
||||||
| ("dotMultiply", [l, r]) => toOkPointwise((#Multiply, l, r))
|
| ("dotMultiply", [l, r]) => toOkPointwise((#Multiply, l, r))
|
||||||
| ("dotMultiply", _) => Error("Dotwise multiplication needs two operands")
|
| ("dotMultiply", _) => Error("Dotwise multiplication needs two operands")
|
||||||
| ("dotPow", [l, r]) => toOkPointwise((#Exponentiate, l, r))
|
| ("dotPow", [l, r]) => toOkPointwise((#Power, l, r))
|
||||||
| ("dotPow", _) => Error("Dotwise exponentiation needs two operands")
|
| ("dotPow", _) => Error("Dotwise exponentiation needs two operands")
|
||||||
| ("rightLogShift", [l, r]) => toOkPointwise((#Add, l, r))
|
| ("rightLogShift", [l, r]) => toOkPointwise((#Add, l, r))
|
||||||
| ("rightLogShift", _) => Error("Dotwise addition needs two operands")
|
| ("rightLogShift", _) => Error("Dotwise addition needs two operands")
|
||||||
|
|
|
@ -18,8 +18,8 @@ module Helpers = {
|
||||||
| "divide" => #Divide
|
| "divide" => #Divide
|
||||||
| "log" => #Logarithm
|
| "log" => #Logarithm
|
||||||
| "dotDivide" => #Divide
|
| "dotDivide" => #Divide
|
||||||
| "pow" => #Exponentiate
|
| "pow" => #Power
|
||||||
| "dotPow" => #Exponentiate
|
| "dotPow" => #Power
|
||||||
| "multiply" => #Multiply
|
| "multiply" => #Multiply
|
||||||
| "dotMultiply" => #Multiply
|
| "dotMultiply" => #Multiply
|
||||||
| "dotLog" => #Logarithm
|
| "dotLog" => #Logarithm
|
||||||
|
|
|
@ -6,12 +6,12 @@ type algebraicOperation = [
|
||||||
| #Multiply
|
| #Multiply
|
||||||
| #Subtract
|
| #Subtract
|
||||||
| #Divide
|
| #Divide
|
||||||
| #Exponentiate
|
| #Power
|
||||||
| #Logarithm
|
| #Logarithm
|
||||||
]
|
]
|
||||||
@genType
|
@genType
|
||||||
type pointwiseOperation = [#Add | #Multiply | #Exponentiate]
|
type pointwiseOperation = [#Add | #Multiply | #Power]
|
||||||
type scaleOperation = [#Multiply | #Exponentiate | #Logarithm | #Divide]
|
type scaleOperation = [#Multiply | #Power | #Logarithm | #Divide]
|
||||||
type distToFloatOperation = [
|
type distToFloatOperation = [
|
||||||
| #Pdf(float)
|
| #Pdf(float)
|
||||||
| #Cdf(float)
|
| #Cdf(float)
|
||||||
|
@ -27,7 +27,7 @@ module Algebraic = {
|
||||||
| #Add => \"+."
|
| #Add => \"+."
|
||||||
| #Subtract => \"-."
|
| #Subtract => \"-."
|
||||||
| #Multiply => \"*."
|
| #Multiply => \"*."
|
||||||
| #Exponentiate => \"**"
|
| #Power => \"**"
|
||||||
| #Divide => \"/."
|
| #Divide => \"/."
|
||||||
| #Logarithm => (a, b) => log(a) /. log(b)
|
| #Logarithm => (a, b) => log(a) /. log(b)
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ module Algebraic = {
|
||||||
| #Add => "+"
|
| #Add => "+"
|
||||||
| #Subtract => "-"
|
| #Subtract => "-"
|
||||||
| #Multiply => "*"
|
| #Multiply => "*"
|
||||||
| #Exponentiate => "**"
|
| #Power => "**"
|
||||||
| #Divide => "/"
|
| #Divide => "/"
|
||||||
| #Logarithm => "log"
|
| #Logarithm => "log"
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ module Pointwise = {
|
||||||
let toString = x =>
|
let toString = x =>
|
||||||
switch x {
|
switch x {
|
||||||
| #Add => "+"
|
| #Add => "+"
|
||||||
| #Exponentiate => "^"
|
| #Power => "^"
|
||||||
| #Multiply => "*"
|
| #Multiply => "*"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ module Scale = {
|
||||||
switch x {
|
switch x {
|
||||||
| #Multiply => \"*."
|
| #Multiply => \"*."
|
||||||
| #Divide => \"/."
|
| #Divide => \"/."
|
||||||
| #Exponentiate => \"**"
|
| #Power => \"**"
|
||||||
| #Logarithm => (a, b) => log(a) /. log(b)
|
| #Logarithm => (a, b) => log(a) /. log(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ module Scale = {
|
||||||
switch operation {
|
switch operation {
|
||||||
| #Multiply => j`verticalMultiply($value, $scaleBy) `
|
| #Multiply => j`verticalMultiply($value, $scaleBy) `
|
||||||
| #Divide => j`verticalDivide($value, $scaleBy) `
|
| #Divide => j`verticalDivide($value, $scaleBy) `
|
||||||
| #Exponentiate => j`verticalExponentiate($value, $scaleBy) `
|
| #Power => j`verticalPower($value, $scaleBy) `
|
||||||
| #Logarithm => j`verticalLog($value, $scaleBy) `
|
| #Logarithm => j`verticalLog($value, $scaleBy) `
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ module Scale = {
|
||||||
switch x {
|
switch x {
|
||||||
| #Multiply => (a, b) => Some(a *. b)
|
| #Multiply => (a, b) => Some(a *. b)
|
||||||
| #Divide => (a, b) => Some(a /. b)
|
| #Divide => (a, b) => Some(a /. b)
|
||||||
| #Exponentiate => (_, _) => None
|
| #Power => (_, _) => None
|
||||||
| #Logarithm => (_, _) => None
|
| #Logarithm => (_, _) => None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ module Scale = {
|
||||||
switch x {
|
switch x {
|
||||||
| #Multiply => (_, _) => None // TODO: this could probably just be multiplied out (using Continuous.scaleBy)
|
| #Multiply => (_, _) => None // TODO: this could probably just be multiplied out (using Continuous.scaleBy)
|
||||||
| #Divide => (_, _) => None
|
| #Divide => (_, _) => None
|
||||||
| #Exponentiate => (_, _) => None
|
| #Power => (_, _) => None
|
||||||
| #Logarithm => (_, _) => None
|
| #Logarithm => (_, _) => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user