Here are the examples of the csharp api System.Math.Exp(double) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1157 Examples
19
View Source File : Mathd.cs
License : MIT License
Project Creator : 734843327
License : MIT License
Project Creator : 734843327
public static double Exp(double power) {
return Math.Exp(power);
}
19
View Source File : SkillCheck.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public static double GetSkillChance(int skill, int difficulty, float factor = 0.03f)
{
var chance = 1.0 - (1.0 / (1.0 + Math.Exp(factor * (skill - difficulty))));
return Math.Min(1.0, Math.Max(0.0, chance));
}
19
View Source File : ExponentialGraphGenerator.cs
License : Apache License 2.0
Project Creator : activey
License : Apache License 2.0
Project Creator : activey
void GenerateDescedants (int level, Graph graph, AbstractGraphNode startNode)
{
if (level > MAX_LEVEL) {
return;
}
for (int index = 0; index < Math.Exp(level); index++) {
AbstractGraphNode descedantNode = graph.NewNode ();
graph.NewEdge (startNode, descedantNode);
GenerateDescedants (level + 1, graph, descedantNode);
}
}
19
View Source File : TestELu.cs
License : MIT License
Project Creator : adamtiger
License : MIT License
Project Creator : adamtiger
[TestMethod]
public void Test_ELu_Execute()
{
double alpha = 1.0;
elu = new ELuLayer(alpha);
Data2D data = new Data2D(2, 3, 1, 1);
data[0, 0, 0, 0] = 4;
data[0, 1, 0, 0] = 2;
data[0, 2, 0, 0] = -2;
data[1, 0, 0, 0] = 3;
data[1, 1, 0, 0] = -1;
data[1, 2, 0, 0] = -3;
elu.SetInput(data);
elu.Execute();
Data2D output = elu.GetOutput() as Data2D;
replacedert.AreEqual(output[0, 0, 0, 0], 4.0, 0.00000001);
replacedert.AreEqual(output[0, 1, 0, 0], 2.0, 0.00000001);
replacedert.AreEqual(output[0, 2, 0, 0], alpha*(Math.Exp(-2) - 1), 0.00000001);
replacedert.AreEqual(output[1, 0, 0, 0], 3.0, 0.00000001);
replacedert.AreEqual(output[1, 1, 0, 0], alpha * (Math.Exp(-1) - 1), 0.00000001);
replacedert.AreEqual(output[1, 2, 0, 0], alpha * (Math.Exp(-3) - 1), 0.00000001);
}
19
View Source File : TestSigmoid.cs
License : MIT License
Project Creator : adamtiger
License : MIT License
Project Creator : adamtiger
private double SigmoidFunc(double x)
{
return 1.0/(1 + Math.Exp(-x));
}
19
View Source File : TestSoftmax.cs
License : MIT License
Project Creator : adamtiger
License : MIT License
Project Creator : adamtiger
[TestMethod]
public void Test_Softmax_Execute()
{
// Softmax output
softmax = new SoftmaxLayer();
Data2D data = new Data2D(1,1,5,1);
data[0,0,0,0] = 0.0;
data[0,0,1,0] = 1.0;
data[0,0,2,0] = 1.5;
data[0,0,3,0] = 2.0;
data[0,0,4,0] = 3.0;
softmax.SetInput(data);
softmax.Execute();
Data2D output = softmax.GetOutput() as Data2D;
// Expected output
double[] expOu = new double[5];
double sum = 0.0;
sum += (Math.Exp(0.0) + Math.Exp(1.0) + Math.Exp(1.5) + Math.Exp(2.0) + Math.Exp(3.0));
expOu[0] = Math.Exp(0.0) / sum;
expOu[1] = Math.Exp(1.0) / sum;
expOu[2] = Math.Exp(1.5) / sum;
expOu[3] = Math.Exp(2.0) / sum;
expOu[4] = Math.Exp(3.0) / sum;
replacedert.AreEqual(output[0,0,0,0], expOu[0], 0.00000001);
replacedert.AreEqual(output[0,0,1,0], expOu[1], 0.00000001);
replacedert.AreEqual(output[0,0,2,0], expOu[2], 0.00000001);
replacedert.AreEqual(output[0,0,3,0], expOu[3], 0.00000001);
replacedert.AreEqual(output[0,0,4,0], expOu[4], 0.00000001);
}
19
View Source File : TestSoftPlus.cs
License : MIT License
Project Creator : adamtiger
License : MIT License
Project Creator : adamtiger
private double SoftPlusFunc(double x)
{
return Math.Log(1 + Math.Exp(x));
}
19
View Source File : TestTanH.cs
License : MIT License
Project Creator : adamtiger
License : MIT License
Project Creator : adamtiger
private double tanh(double x)
{
return 2.0 / (1 + Math.Exp(-2 * x)) - 1.0;
}
19
View Source File : SigmoidKernel.cs
License : MIT License
Project Creator : adamtiger
License : MIT License
Project Creator : adamtiger
public static void SigmoidLambda(IData data)
{
data.ApplyToAll(p =>
{
return 1.0 / (1.0 + Math.Exp(-p));
});
}
19
View Source File : SoftmaxKernel.cs
License : MIT License
Project Creator : adamtiger
License : MIT License
Project Creator : adamtiger
public static void SoftmaxLambda(IData data)
{
Data2D dat = data as Data2D;
for (int b = 0; b < dat.GetDimension().b; ++b)
{
double sum = 0.0;
for (int i = 0; i < dat.GetDimension().c; ++i)
{
sum += Math.Exp(dat[0, 0, i, b]);
}
for (int i = 0; i < dat.GetDimension().c; ++i)
{
dat[0, 0, i, b] = Math.Exp(dat[0, 0, i, b]) / sum;
}
}
}
19
View Source File : ELuKernel.cs
License : MIT License
Project Creator : adamtiger
License : MIT License
Project Creator : adamtiger
public static void ELuLambda(IData data)
{
data.ApplyToAll( p =>
{
if (p >= 0.0)
return p;
else
{
return 1.0 * (Math.Exp(p) - 1.0);
}
});
}
19
View Source File : SoftPlusKernel.cs
License : MIT License
Project Creator : adamtiger
License : MIT License
Project Creator : adamtiger
public static void SoftPlusLambda(IData data)
{
data.ApplyToAll(p =>
{
return Math.Log(1 + Math.Exp(p));
});
}
19
View Source File : TanHKernel.cs
License : MIT License
Project Creator : adamtiger
License : MIT License
Project Creator : adamtiger
public static void TanHLambda(IData data)
{
data.ApplyToAll(p =>
{
return 2.0 / (1 + Math.Exp(-2.0 * p)) - 1.0;
});
}
19
View Source File : BigDecimal.cs
License : MIT License
Project Creator : AdamWhiteHat
License : MIT License
Project Creator : AdamWhiteHat
public static BigDecimal Exp(double exponent)
{
BigDecimal tmp = (BigDecimal)1;
while (Math.Abs(exponent) > 100)
{
int diff = exponent > 0 ? 100 : -100;
tmp *= Math.Exp(diff);
exponent -= diff;
}
return tmp * Math.Exp(exponent);
}
19
View Source File : BigDecimal.cs
License : MIT License
Project Creator : AdamWhiteHat
License : MIT License
Project Creator : AdamWhiteHat
public static BigDecimal Exp(BigInteger exponent)
{
BigDecimal tmp = (BigDecimal)1;
while (BigInteger.Abs(exponent) > 100)
{
int diff = exponent > 0 ? 100 : -100;
tmp *= Math.Exp(diff);
exponent -= diff;
}
double exp = (double)exponent;
return (tmp * Math.Exp(exp));
}
19
View Source File : ObjectTracker.cs
License : GNU General Public License v3.0
Project Creator : ahmed605
License : GNU General Public License v3.0
Project Creator : ahmed605
private void Zoom(Point currentPosition)
{
double yDelta = _previousPosition2D.Y - currentPosition.Y;
double scale = Math.Exp(yDelta / 100); // e^(yDelta/100) is fairly arbitrary.
_scale.ScaleX *= scale;
_scale.ScaleY *= scale;
_scale.ScaleZ *= scale;
}
19
View Source File : Math.cs
License : Mozilla Public License 2.0
Project Creator : ahyahy
License : Mozilla Public License 2.0
Project Creator : ahyahy
[ContextMethod("Экспонента", "Exp")]
public double Exp(double p1)
{
return System.Math.Exp(p1);
}
19
View Source File : CheapRuler.cs
License : MIT License
Project Creator : alen-smajic
License : MIT License
Project Creator : alen-smajic
public static CheapRuler FromTile(int y, int z, CheapRulerUnits units = CheapRulerUnits.Kilometers)
{
var n = Math.PI * (1 - 2 * (y + 0.5) / Math.Pow(2, z));
var lat = Math.Atan(0.5 * (Math.Exp(n) - Math.Exp(-n))) * 180 / Math.PI;
return new CheapRuler(lat, units);
}
19
View Source File : Conversions.cs
License : MIT License
Project Creator : alen-smajic
License : MIT License
Project Creator : alen-smajic
public static Vector2d MetersToLatLon(Vector2d m)
{
var vx = (m.x / OriginShift) * 180;
var vy = (m.y / OriginShift) * 180;
vy = 180 / Math.PI * (2 * Math.Atan(Math.Exp(vy * Math.PI / 180)) - Math.PI / 2);
return new Vector2d(vy, vx);
}
19
View Source File : MercatorProjection.cs
License : MIT License
Project Creator : alen-smajic
License : MIT License
Project Creator : alen-smajic
public static double yToLat(double y)
{
double ts = Math.Exp(-y / R_MAJOR);
double phi = PI_2 - 2 * Math.Atan(ts);
double dphi = 1.0;
int i = 0;
while ((Math.Abs(dphi) > 0.000000001) && (i < 15))
{
double con = ECCENT * Math.Sin(phi);
dphi = PI_2 - 2 * Math.Atan(ts * Math.Pow((1.0 - con) / (1.0 + con), COM)) - phi;
phi += dphi;
i++;
}
return RadToDeg(phi);
}
19
View Source File : LogarithmicAxis.cs
License : MIT License
Project Creator : AlexGyver
License : MIT License
Project Creator : AlexGyver
internal override double PostInverseTransform(double x)
{
return Math.Exp(x);
}
19
View Source File : LogarithmicAxis.cs
License : MIT License
Project Creator : AlexGyver
License : MIT License
Project Creator : AlexGyver
internal override void UpdateActualMaxMin()
{
if (this.PowerPadding)
{
double logBase = Math.Log(this.Base);
var e0 = (int)Math.Floor(Math.Log(this.ActualMinimum) / logBase);
var e1 = (int)Math.Ceiling(Math.Log(this.ActualMaximum) / logBase);
if (!double.IsNaN(this.ActualMinimum))
{
this.ActualMinimum = Math.Exp(e0 * logBase).RemoveNoiseFromDoubleMath();
}
if (!double.IsNaN(this.ActualMaximum))
{
this.ActualMaximum = Math.Exp(e1 * logBase).RemoveNoiseFromDoubleMath();
}
}
base.UpdateActualMaxMin();
}
19
View Source File : Exp.cs
License : MIT License
Project Creator : alexshtf
License : MIT License
Project Creator : alexshtf
public override void Diff()
{
Value = Math.Exp(Arg.Value);
Inputs.SetWeight(ArgIdx, Value);
}
19
View Source File : BasicDifferentiationTests.cs
License : MIT License
Project Creator : alexshtf
License : MIT License
Project Creator : alexshtf
[Fact]
public void DiffExp()
{
var x = new Variable();
var func = Exp(x);
var grad1 = func.Differentiate(Vec(x), NumVec(1));
var grad2 = func.Differentiate(Vec(x), NumVec(-2));
replacedert.Equal(NumVec(Math.Exp(1)), grad1);
replacedert.Equal(NumVec(Math.Exp(-2)), grad2);
}
19
View Source File : Exp.cs
License : MIT License
Project Creator : alexshtf
License : MIT License
Project Creator : alexshtf
public override void Eval()
{
Value = Math.Exp(Arg.Value);
}
19
View Source File : Distributions.cs
License : Apache License 2.0
Project Creator : alexyakunin
License : Apache License 2.0
Project Creator : alexyakunin
public static double Sample(StdRandom random, double mu, double sigma) =>
Math.Exp(NormalDistribution.Sample(random, mu, sigma));
19
View Source File : GlobalMercator.cs
License : MIT License
Project Creator : AliFlux
License : MIT License
Project Creator : AliFlux
public CoordinatePair MetersToLatLon(double mx, double my)
{
CoordinatePair retval = new CoordinatePair();
try
{
retval.X = (mx / this.originShift) * 180.0;
retval.Y = (my / this.originShift) * 180.0;
retval.Y = 180 / Math.PI * (2 * Math.Atan(Math.Exp(retval.Y * Math.PI / 180.0)) - Math.PI / 2.0);
return retval;
}
catch (Exception ex)
{
throw ex;
}
}
19
View Source File : DoubleExtension.cs
License : MIT License
Project Creator : AlphaYu
License : MIT License
Project Creator : AlphaYu
public static double Exp(this double d)
{
return Math.Exp(d);
}
19
View Source File : Program.cs
License : MIT License
Project Creator : altimesh
License : MIT License
Project Creator : altimesh
[MethodImpl(MethodImplOptions.AggressiveInlining), IntrinsicFunction("expf")]
public static float Expf(float f)
{
return (float)Math.Exp((double)f);
}
19
View Source File : Program.cs
License : MIT License
Project Creator : altimesh
License : MIT License
Project Creator : altimesh
[MethodImpl(MethodImplOptions.AggressiveInlining), IntrinsicFunction("__expf")]
public static float Expf(float f)
{
return (float)Math.Exp((double)f);
}
19
View Source File : Test2.cs
License : MIT License
Project Creator : Aminator
License : MIT License
Project Creator : Aminator
[ShaderMethod]
public static float Sigmoid(float x)
{
return 1 / (1 + (float)Math.Exp(-x));
}
19
View Source File : Program.cs
License : MIT License
Project Creator : anastasios-stamoulis
License : MIT License
Project Creator : anastasios-stamoulis
int sample(Random random, float[] preds, double temperature=1.0) {
// step 1: apply temperature to predictions, and normalize them to create a probability distribution
float sum = 0;
for (int i=0; i<preds.Length; i++) {
var p = (float)Math.Exp((Math.Log(Math.Max(preds[i], 1e-10)) / temperature));
sum += p;
preds[i] = p;
}
for (int i = 0; i < preds.Length; i++) { preds[i] /= sum; }
// step 2: draw a random sample from this distribution
var d = random.NextDouble();
sum = 0;
for (int i=0; i<preds.Length; i++) {
sum += preds[i];
if ( d<sum ) { return i; }
}
return preds.Length - 1;
}
19
View Source File : BetaDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public double Pdf(double x)
{
if (x < 0 || x > 1)
return 0;
if (x < 1e-9)
{
if (Alpha > 1)
return 0;
if (Abs(Alpha - 1) < 1e-9)
return Beta;
return double.PositiveInfinity;
}
if (x > 1 - 1e-9)
{
if (Beta > 1)
return 0;
if (Abs(Beta - 1) < 1e-9)
return Alpha;
return double.PositiveInfinity;
}
if (Alpha < 1e-9 || Beta < 1e-9)
return 0;
return Exp((Alpha - 1) * Log(x) + (Beta - 1) * Log(1 - x) - BetaFunction.CompleteLogValue(Alpha, Beta));
}
19
View Source File : ExponentialDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public double Pdf(double x)
{
if (x < 0)
return 0;
return Rate * Exp(-Rate * x);
}
19
View Source File : ExponentialDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public double Cdf(double x)
{
if (x < 0)
return 0;
return 1 - Exp(-Rate * x);
}
19
View Source File : FrechetDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public double Pdf(double x)
{
if (x <= M)
return 0;
double z = Z(x);
return A / S * Pow(z, -1 - A) * Exp(-Pow(z, -A));
}
19
View Source File : FrechetDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public double Cdf(double x)
{
if (x <= M)
return 0;
return Exp(-Pow(Z(x), -A));
}
19
View Source File : GumbelDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public double Pdf(double x)
{
double z = Z(x);
return Exp(-(z + Exp(-z))) / S;
}
19
View Source File : GumbelDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public double Cdf(double x) => Exp(-Exp(-Z(x)));
19
View Source File : LaplaceDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public double Pdf(double x) => Exp(-Abs(x - Mu) / Sigma) / 2 / Sigma;
19
View Source File : LaplaceDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public double Cdf(double x) => x <= Mu
? Exp((x - Mu) / Sigma) / 2
: 1 - Exp(-(x - Mu) / Sigma) / 2;
19
View Source File : LogNormalDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public double Pdf(double x)
{
if (x < 1e-9)
return 0;
return Exp(-(Log(x) - Mean).Sqr() / (2 * StandardDeviation.Sqr())) / (x * StandardDeviation * Constants.Sqrt2Pi);
}
19
View Source File : LogNormalDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public double Quantile(Probability p)
{
if (p < 1e-9)
return 0;
if (p > 1 - 1e-9)
return double.PositiveInfinity;
return Exp(Mean + Constants.Sqrt2 * StandardDeviation * ErrorFunction.InverseValue(2 * p - 1));
}
19
View Source File : LogNormalDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public override double Next() => Exp(normalRandomGenerator.Next());
19
View Source File : NormalDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public double Pdf(double x) => Exp(-((x - Mean) / StandardDeviation).Sqr() / 2) / (StandardDeviation * Sqrt(2 * PI));
19
View Source File : StudentDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public double Pdf(double x)
{
double df2 = (df + 1) / 2;
// Ln( Г((df + 1) / 2) / Г(df / 2) )
double term1 = GammaFunction.LogValue(df2) - GammaFunction.LogValue(df / 2);
// Ln( (1 + x^2 / df) ^ (-(df + 1) / 2) )
double term2 = Log(1 + x.Sqr() / df) * -df2;
return Exp(term1 + term2) / Sqrt(PI * df);
}
19
View Source File : TukeyGhDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public double Quantile(Probability p)
{
if (Abs(p) < 1e-9)
return double.NegativeInfinity;
if (Abs(p) > 1 - 1e-9)
return double.PositiveInfinity;
double z = NormalDistribution.Standard.Quantile(p);
return Abs(G) < 1e-9
? Mu + Sigma * z * Exp(H * z * z / 2)
: Mu + Sigma * (Exp(G * z) - 1) * Exp(H * z * z / 2) / G;
}
19
View Source File : WeibullDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public double Pdf(double x) => x < 0 ? 0 : K / Lambda * Pow(x / Lambda, K - 1) * Exp(-Pow(x / Lambda, K));
19
View Source File : WeibullDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public double Cdf(double x) => x < 0 ? 0 : 1 - Exp(-Pow(x / Lambda, K));
19
View Source File : BinomialDistribution.cs
License : MIT License
Project Creator : AndreyAkinshin
License : MIT License
Project Creator : AndreyAkinshin
public double Pmf(int k)
{
if (k < 0 || k > N)
return 0;
return Math.Exp(
BinomialCoefficientHelper.GetLogBinomialCoefficient(N, k) +
k * Math.Log(P) +
(N - k) * Math.Log(1 - P)
);
}
See More Examples