本文整理汇总了C#中MathNet.Numerics.Distributions.StudentT类的典型用法代码示例。如果您正苦于以下问题:C# StudentT类的具体用法?C# StudentT怎么用?C# StudentT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StudentT类属于MathNet.Numerics.Distributions命名空间,在下文中一共展示了StudentT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanCreateStudentT
public void CanCreateStudentT(double location, double scale, double dof)
{
var n = new StudentT(location, scale, dof);
Assert.AreEqual(location, n.Location);
Assert.AreEqual(scale, n.Scale);
Assert.AreEqual(dof, n.DegreesOfFreedom);
}
示例2: CanCreateStandardStudentT
public void CanCreateStandardStudentT()
{
var n = new StudentT();
Assert.AreEqual(0.0, n.Location);
Assert.AreEqual(1.0, n.Scale);
Assert.AreEqual(1.0, n.DegreesOfFreedom);
}
示例3: ValidateMode
public void ValidateMode(double location, double scale, double dof)
{
var n = new StudentT(location, scale, dof);
Assert.AreEqual(location, n.Mode);
}
示例4: ValidateMinimum
public void ValidateMinimum()
{
var n = new StudentT();
Assert.AreEqual(Double.NegativeInfinity, n.Minimum);
}
示例5: ComputeCorrelation
public static CorrelData ComputeCorrelation(IEnumerable<double> d1, IEnumerable<double> d2)
{
CorrelData oRet = null;
if ((d1 == null) || (d2 == null))
{
return null;
}
double[] dd1 = d1.ToArray();
double[] dd2 = d2.ToArray();
int n = (dd1.Length < dd2.Length) ? dd1.Length : dd2.Length;
if (n < 3)
{
return null;
}
oRet = new CorrelData();
oRet.Count = n;
double corr = myconvert10000(Correlation.Pearson(dd1.Take(n), dd2.Take(n)));
if (corr < -1.0)
{
corr = -1.0;
}
if (corr > 1.0)
{
corr = 1.0;
}
oRet.Value = corr;
double xn = (double)n;
double rr = (corr < 0.0) ? -corr : corr;
double crit = rr * Math.Sqrt(xn - 2.0) / Math.Sqrt(1.0 - rr * rr);
StudentT st = new StudentT(0.0, 1.0, xn - 2);
double pb = st.CumulativeDistribution(crit);
oRet.Probability = myconvert10000(1.0 - pb);
double s1 = 0.5 * Math.Log((1.0 + corr) / (1.0 - corr));
double s2 = 1.96 / Math.Sqrt(xn - 3.0);
double s3 = corr / Math.Sqrt(xn - 1.0);
double z1 = s1 - s2 - s3;
double z2 = s1 + s2 - s3;
oRet.Minimum = myconvert10000(Math.Tanh(z1));
oRet.Maximum = myconvert10000(Math.Tanh(z2));
return oRet;
}
示例6: DT
/// <summary>
/// Density function for a Student's T distribution for a specified number
/// of degrees of freedom.
/// </summary>
public static double DT(double value, double df, double location = 0, double scale = 1)
{
var tdist = new StudentT(location, scale, df);
return tdist.Density(value);
}
示例7: CanSampleSequence
public void CanSampleSequence()
{
var n = new StudentT();
var ied = n.Samples();
ied.Take(5).ToArray();
}
示例8: ValidateVariance
public void ValidateVariance(double location, double scale, double dof, double var)
{
var n = new StudentT(location, scale, dof);
Assert.AreEqual(var, n.Variance);
}
示例9: SetDofFailsWithNonPositiveDoF
public void SetDofFailsWithNonPositiveDoF(double dof)
{
var n = new StudentT();
Assert.Throws<ArgumentOutOfRangeException>(() => n.DegreesOfFreedom = dof);
}
示例10: ValidateInverseCumulativeDistribution
public void ValidateInverseCumulativeDistribution(double location, double scale, double dof, double x, double p)
{
var dist = new StudentT(location, scale, dof);
Assert.That(dist.InverseCumulativeDistribution(p), Is.EqualTo(x).Within(1e-6));
Assert.That(StudentT.InvCDF(location, scale, dof, p), Is.EqualTo(x).Within(1e-6));
}
示例11: ValidateCumulativeDistribution
public void ValidateCumulativeDistribution(double location, double scale, double dof, double x, double p)
{
var dist = new StudentT(location, scale, dof);
Assert.That(dist.CumulativeDistribution(x), Is.EqualTo(p).Within(1e-13));
Assert.That(StudentT.CDF(location, scale, dof, x), Is.EqualTo(p).Within(1e-13));
}
示例12: Fit
public IList<LinearFitResult> Fit(double[] observations)
{
if (observations.Length != DesignMatrix.RowCount)
{
throw new ArgumentException("Wrong number of rows"); // Not L10N
}
var coefficients = QrFactorization.Solve(observations);
var fittedValues = new double[observations.Length];
var residuals = new double[observations.Length];
for (int iRow = 0; iRow < observations.Length; iRow++)
{
var designRow = Enumerable.Range(0, DesignMatrix.ColumnCount).Select(index => DesignMatrix[iRow, index]).ToArray();
fittedValues[iRow] = DotProduct(designRow, coefficients);
residuals[iRow] = observations[iRow] - fittedValues[iRow];
}
double rss = DotProduct(residuals, residuals);
int degreesOfFreedom = observations.Length - QrFactorization.NumberIndependentColumns;
double resVar = rss / degreesOfFreedom;
double sigma = Math.Sqrt(resVar);
var covarianceUnscaled = MatrixCrossproductInverse;
var scaledCovariance = covarianceUnscaled.Multiply(sigma * sigma);
var indepColIndexes = QrFactorization.IndependentColumnIndexes.ToArray();
var result = new List<LinearFitResult>();
foreach (var contrastRow in ContrastValues.EnumerateRows())
{
double standardError = 0;
for (int iRow = 0; iRow < indepColIndexes.Length; iRow++)
{
for (int iCol = 0; iCol < indepColIndexes.Length; iCol++)
{
standardError += contrastRow[indepColIndexes[iRow]] * scaledCovariance[iRow, iCol] * contrastRow[indepColIndexes[iCol]];
}
}
standardError = Math.Sqrt(standardError);
double foldChange = DotProduct(coefficients, contrastRow);
double tValue = foldChange / standardError;
double pValue;
if (0 != degreesOfFreedom)
{
var studentT = new StudentT(0, 1.0, degreesOfFreedom);
pValue = (1 - studentT.CumulativeDistribution(Math.Abs(tValue))) * 2;
}
else
{
pValue = 1;
}
result.Add(new LinearFitResult(foldChange)
.SetDegreesOfFreedom(degreesOfFreedom)
.SetTValue(tValue)
.SetStandardError(standardError)
.SetPValue(pValue));
}
return result;
}
示例13: SetScaleFailsWithNonPositiveScale
public void SetScaleFailsWithNonPositiveScale(double scale)
{
var n = new StudentT();
Assert.That(() => n.Scale = scale, Throws.ArgumentException);
}
示例14: SetDofFailsWithNonPositiveDoF
public void SetDofFailsWithNonPositiveDoF(double dof)
{
var n = new StudentT();
Assert.That(() => n.DegreesOfFreedom = dof, Throws.ArgumentException);
}
示例15: ValidateStdDev
public void ValidateStdDev(double location, double scale, double dof, double sdev)
{
var n = new StudentT(location, scale, dof);
Assert.AreEqual(sdev, n.StdDev);
}