/// @return double a random number distributed according to the receiver. public override double Random() { if (_chiSquareDistribution1 == null) { _chiSquareDistribution1 = new ChiSquareDistribution(_dof1); _chiSquareDistribution2 = new ChiSquareDistribution(_dof2); } return(_chiSquareDistribution1.Random() * _dof2 / (_chiSquareDistribution2.Random() * _dof1)); }
/// Assigns new degrees of freedom to the receiver. /// Compute the norm of the distribution after a change of parameters. /// @param n1 int first degree of freedom /// @param n2 int second degree of freedom public void DefineParameters(int n1, int n2) { _dof1 = n1; _dof2 = n2; double nn1 = 0.5 * n1; double nn2 = 0.5 * n2; _norm = nn1 * Math.Log(n1) + nn2 * Math.Log(n2) - GammaFunction.LogBeta(nn1, nn2); _incompleteBetaFunction = null; _chiSquareDistribution1 = null; _chiSquareDistribution2 = null; }