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
Source : Mathd.cs
with MIT License
from 734843327
with MIT License
from 734843327
public static double Exp(double power) {
return Math.Exp(power);
}
19
Source : SkillCheck.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from 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
Source : ExponentialGraphGenerator.cs
with Apache License 2.0
from activey
with Apache License 2.0
from 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
Source : TestELu.cs
with MIT License
from adamtiger
with MIT License
from 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
Source : TestSigmoid.cs
with MIT License
from adamtiger
with MIT License
from adamtiger
private double SigmoidFunc(double x)
{
return 1.0/(1 + Math.Exp(-x));
}
19
Source : TestSoftmax.cs
with MIT License
from adamtiger
with MIT License
from 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
Source : TestSoftPlus.cs
with MIT License
from adamtiger
with MIT License
from adamtiger
private double SoftPlusFunc(double x)
{
return Math.Log(1 + Math.Exp(x));
}
19
Source : TestTanH.cs
with MIT License
from adamtiger
with MIT License
from adamtiger
private double tanh(double x)
{
return 2.0 / (1 + Math.Exp(-2 * x)) - 1.0;
}
19
Source : SigmoidKernel.cs
with MIT License
from adamtiger
with MIT License
from adamtiger
public static void SigmoidLambda(IData data)
{
data.ApplyToAll(p =>
{
return 1.0 / (1.0 + Math.Exp(-p));
});
}
19
Source : SoftmaxKernel.cs
with MIT License
from adamtiger
with MIT License
from 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
Source : ELuKernel.cs
with MIT License
from adamtiger
with MIT License
from 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
Source : SoftPlusKernel.cs
with MIT License
from adamtiger
with MIT License
from adamtiger
public static void SoftPlusLambda(IData data)
{
data.ApplyToAll(p =>
{
return Math.Log(1 + Math.Exp(p));
});
}
19
Source : TanHKernel.cs
with MIT License
from adamtiger
with MIT License
from adamtiger
public static void TanHLambda(IData data)
{
data.ApplyToAll(p =>
{
return 2.0 / (1 + Math.Exp(-2.0 * p)) - 1.0;
});
}
19
Source : BigDecimal.cs
with MIT License
from AdamWhiteHat
with MIT License
from 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
Source : BigDecimal.cs
with MIT License
from AdamWhiteHat
with MIT License
from 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
Source : ObjectTracker.cs
with GNU General Public License v3.0
from ahmed605
with GNU General Public License v3.0
from 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
Source : Math.cs
with Mozilla Public License 2.0
from ahyahy
with Mozilla Public License 2.0
from ahyahy
[ContextMethod("Экспонента", "Exp")]
public double Exp(double p1)
{
return System.Math.Exp(p1);
}
19
Source : CheapRuler.cs
with MIT License
from alen-smajic
with MIT License
from 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
Source : Conversions.cs
with MIT License
from alen-smajic
with MIT License
from 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
Source : MercatorProjection.cs
with MIT License
from alen-smajic
with MIT License
from 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
Source : LogarithmicAxis.cs
with MIT License
from AlexGyver
with MIT License
from AlexGyver
internal override double PostInverseTransform(double x)
{
return Math.Exp(x);
}
19
Source : LogarithmicAxis.cs
with MIT License
from AlexGyver
with MIT License
from 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
Source : Exp.cs
with MIT License
from alexshtf
with MIT License
from alexshtf
public override void Diff()
{
Value = Math.Exp(Arg.Value);
Inputs.SetWeight(ArgIdx, Value);
}
19
Source : BasicDifferentiationTests.cs
with MIT License
from alexshtf
with MIT License
from 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
Source : Exp.cs
with MIT License
from alexshtf
with MIT License
from alexshtf
public override void Eval()
{
Value = Math.Exp(Arg.Value);
}
19
Source : Distributions.cs
with Apache License 2.0
from alexyakunin
with Apache License 2.0
from alexyakunin
public static double Sample(StdRandom random, double mu, double sigma) =>
Math.Exp(NormalDistribution.Sample(random, mu, sigma));
19
Source : GlobalMercator.cs
with MIT License
from AliFlux
with MIT License
from 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
Source : DoubleExtension.cs
with MIT License
from AlphaYu
with MIT License
from AlphaYu
public static double Exp(this double d)
{
return Math.Exp(d);
}
19
Source : Program.cs
with MIT License
from altimesh
with MIT License
from altimesh
[MethodImpl(MethodImplOptions.AggressiveInlining), IntrinsicFunction("expf")]
public static float Expf(float f)
{
return (float)Math.Exp((double)f);
}
19
Source : Program.cs
with MIT License
from altimesh
with MIT License
from altimesh
[MethodImpl(MethodImplOptions.AggressiveInlining), IntrinsicFunction("__expf")]
public static float Expf(float f)
{
return (float)Math.Exp((double)f);
}
19
Source : Test2.cs
with MIT License
from Aminator
with MIT License
from Aminator
[ShaderMethod]
public static float Sigmoid(float x)
{
return 1 / (1 + (float)Math.Exp(-x));
}
19
Source : Program.cs
with MIT License
from anastasios-stamoulis
with MIT License
from 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
Source : BetaDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from 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
Source : ExponentialDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from AndreyAkinshin
public double Pdf(double x)
{
if (x < 0)
return 0;
return Rate * Exp(-Rate * x);
}
19
Source : ExponentialDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from AndreyAkinshin
public double Cdf(double x)
{
if (x < 0)
return 0;
return 1 - Exp(-Rate * x);
}
19
Source : FrechetDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from 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
Source : FrechetDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from AndreyAkinshin
public double Cdf(double x)
{
if (x <= M)
return 0;
return Exp(-Pow(Z(x), -A));
}
19
Source : GumbelDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from AndreyAkinshin
public double Pdf(double x)
{
double z = Z(x);
return Exp(-(z + Exp(-z))) / S;
}
19
Source : GumbelDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from AndreyAkinshin
public double Cdf(double x) => Exp(-Exp(-Z(x)));
19
Source : LaplaceDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from AndreyAkinshin
public double Pdf(double x) => Exp(-Abs(x - Mu) / Sigma) / 2 / Sigma;
19
Source : LaplaceDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from AndreyAkinshin
public double Cdf(double x) => x <= Mu
? Exp((x - Mu) / Sigma) / 2
: 1 - Exp(-(x - Mu) / Sigma) / 2;
19
Source : LogNormalDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from 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
Source : LogNormalDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from 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
Source : LogNormalDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from AndreyAkinshin
public override double Next() => Exp(normalRandomGenerator.Next());
19
Source : NormalDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from AndreyAkinshin
public double Pdf(double x) => Exp(-((x - Mean) / StandardDeviation).Sqr() / 2) / (StandardDeviation * Sqrt(2 * PI));
19
Source : StudentDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from 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
Source : TukeyGhDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from 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
Source : WeibullDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from AndreyAkinshin
public double Pdf(double x) => x < 0 ? 0 : K / Lambda * Pow(x / Lambda, K - 1) * Exp(-Pow(x / Lambda, K));
19
Source : WeibullDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from AndreyAkinshin
public double Cdf(double x) => x < 0 ? 0 : 1 - Exp(-Pow(x / Lambda, K));
19
Source : BinomialDistribution.cs
with MIT License
from AndreyAkinshin
with MIT License
from 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