public abstract class MultivariateContinuousDistribution
{
private int order;
public int Order => this.order;
protected MultivariateContinuousDistribution(int order)
{
this.order = order;
}
public GeneralVector GetRandomVariate(System.Random random)
{
if (random == null)
{
ThrowException.ArgumentNull("random");
}
GeneralVector generalVector;
generalVector = Vector.Create(this.order);
this.FillRandomVariate(random, generalVector);
return generalVector;
}
public void FillRandomVariate(System.Random random, Vector sample)
{
if (random == null)
{
ThrowException.ArgumentNull("random");
}
if (sample == null)
{
ThrowException.ArgumentNull("sample");
}
if (sample.Length != this.order)
{
throw new DimensionMismatchException(DimensionType.Length, "sample", DimensionType.Unknown, "Order");
}
this.FillRandomVariateCore(random, sample);
}
protected abstract void FillRandomVariateCore(System.Random random, Vector sample);
public void FillRandomVariate(System.Random random, double[] sample)
{
if (sample == null)
{
ThrowException.ArgumentNull("sample");
}
if (random == null)
{
ThrowException.ArgumentNull("random");
}
this.FillRandomVariate(random, new GeneralVector(sample, reuseComponentArray: true));
}
public virtual GeneralMatrix GetRandomVariates(System.Random random, int count)
{
if (random == null)
{
ThrowException.ArgumentNull("random");
}
if (count < 0)
{
ThrowException.ArgumentOutOfRange("count");
}
GeneralMatrix generalMatrix;
generalMatrix = Matrix.Create(count, this.order);
this.FillRandomVariates(random, generalMatrix);
return generalMatrix;
}
public virtual void FillRandomVariates(System.Random random, Matrix samples)
{
if (random == null)
{
ThrowException.ArgumentNull("random");
}
if (samples == null)
{
ThrowException.ArgumentNull("samples");
}
if (samples.ColumnCount != this.order)
{
throw new DimensionMismatchException(DimensionType.Row, "samples", DimensionType.Unknown, "Order");
}
foreach (Vector row in samples.Rows)
{
this.FillRandomVariateCore(random, row);
}
}
public double ProbabilityDensityFunction(Vector x)
{
return Math.Exp(this.LogProbabilityDensityFunction(x));
}
public abstract double LogProbabilityDensityFunction(Vector x);
public abstract Vector GetMeans();
public abstract SymmetricMatrix GetVarianceCovarianceMatrix();
}
如果对您有帮忙,非常感谢您支持一下创造者的付出!
感谢支持技术分享,请扫码点赞支持:
技术合作交流qq:2401315930