1 文本格式
using System;
namespace Legalsoft.Truffer
{
public class Gammadev : Normaldev
{
private double alph { get; set; }
private double oalph { get; set; }
private double bet { get; set; }
private double a1 { get; set; }
private double a2 { get; set; }
public Gammadev(double aalph, double bbet, ulong i) : base(0.0, 1.0, i)
{
this.alph = aalph;
this.oalph = aalph;
this.bet = bbet;
if (alph <= 0.0)
{
throw new Exception("bad alph in Gammadev");
}
if (alph < 1.0)
{
alph += 1.0;
}
a1 = alph - 1.0 / 3.0;
a2 = 1.0 / Math.Sqrt(9.0 * a1);
}
public new double dev()
{
double u;
double v;
double x;
do
{
do
{
x = base.dev();
v = 1.0 + a2 * x;
} while (v <= 0.0);
v = v * v * v;
u = doub();
} while (u > 1.0 - 0.331 * Globals.SQR(Globals.SQR(x)) && Math.Log(u) > 0.5 * Globals.SQR(x) + a1 * (1.0 - v + Math.Log(v)));
//if (alph == oalph)
if (Math.Abs(alph - oalph) <= float.Epsilon)
{
return a1 * v / bet;
}
else
{
do
{
u = doub();
} while (Math.Abs(u) <= float.Epsilon);// (u == 0.0);
return Math.Pow(u, 1.0 / oalph) * a1 * v / bet;
}
}
}
}
2 代码格式
using System;
namespace Legalsoft.Truffer
{
public class Gammadev : Normaldev
{
private double alph { get; set; }
private double oalph { get; set; }
private double bet { get; set; }
private double a1 { get; set; }
private double a2 { get; set; }
public Gammadev(double aalph, double bbet, ulong i) : base(0.0, 1.0, i)
{
this.alph = aalph;
this.oalph = aalph;
this.bet = bbet;
if (alph <= 0.0)
{
throw new Exception("bad alph in Gammadev");
}
if (alph < 1.0)
{
alph += 1.0;
}
a1 = alph - 1.0 / 3.0;
a2 = 1.0 / Math.Sqrt(9.0 * a1);
}
public new double dev()
{
double u;
double v;
double x;
do
{
do
{
x = base.dev();
v = 1.0 + a2 * x;
} while (v <= 0.0);
v = v * v * v;
u = doub();
} while (u > 1.0 - 0.331 * Globals.SQR(Globals.SQR(x)) && Math.Log(u) > 0.5 * Globals.SQR(x) + a1 * (1.0 - v + Math.Log(v)));
//if (alph == oalph)
if (Math.Abs(alph - oalph) <= float.Epsilon)
{
return a1 * v / bet;
}
else
{
do
{
u = doub();
} while (Math.Abs(u) <= float.Epsilon);// (u == 0.0);
return Math.Pow(u, 1.0 / oalph) * a1 * v / bet;
}
}
}
}