Na podstawie artykułu wiki, który pisał, że można zbliżyć wartości funkcji hypergeometric użyciu tego kodu, który napisałem:
Jako następny krok, może być możliwe do oszacowania Błąd przybliżenie.
/**
* The generalized hypergeometric function is a convergent power series \sum_{i=0}^{\infty} c_i x^i
* where the coefficients satisfy c_{n+1}/c_n = A(n)/B(n) for some polynomials A and B in n.
* It is customary to factor out the leading term, so c_0 is assumed to be 1
*/
public class HypergeometricFunction {
private final int degreeOfApproximation;
private final double[] coefficientsOfA;
private final double[] coefficientsOfB;
private final double[] coefficientsOfHypergeometricFunction;
public HypergeometricFunction(int degreeOfApproximation, double[] coefficientsOfA, double[] coefficientsOfB) {
this.degreeOfApproximation = degreeOfApproximation;
this.coefficientsOfA = coefficientsOfA;
this.coefficientsOfB = coefficientsOfB;
this.coefficientsOfHypergeometricFunction = generateCoefficients();
}
/**
* @param x input
* @return Approximation to the hypergeometric function by taking the first
* {@code degreeOfApproximation} terms from the series.
*/
public double approximate(double x){
return evaluatePolynomial(x, coefficientsOfHypergeometricFunction);
}
private double[] generateCoefficients() {
double[] coefficients = new double[degreeOfApproximation];
coefficients[0] = 1;
for (int i = 1; i < degreeOfApproximation; i++)
coefficients[i] = (evaluatePolynomial(i, coefficientsOfA)/evaluatePolynomial(i, coefficientsOfB)) * coefficients[i - 1];
return coefficients;
}
private double evaluatePolynomial(double n, double[] coefficients) {
int length = coefficients.length;
double out = 0.0D;
for (int i = 0; i < length; i++) {
out += coefficients[i] * pow(n, i);
}
return out;
}
private double pow(double a, int b) {
double out = 1;
for (int i = 0; i < b; i++) out *= a;
return out;
}
}
Jeśli zbieżny serii (a tym samym zapewnia prawidłowe funkcjonowanie hipergeometryczny), następnie lim[c_i*x^i]
musi wynosić zero, więc powinno to stanowić przybliżenie jeśli wziąć degreeOfApproximation
być wystarczająco duża.
Wielomiany A i B są tymi, o których mowa w artykule wiki, i aby użyć tego kodu, należy dostarczyć tablice współczynników dla tych wielomianów do konstruktora, wraz z pożądanym stopniem przybliżenia.
Mam nadzieję, że to pomoże.
Dzięki za odpowiedź. Popełniłem błąd w temacie. Powinna to być uogólniona funkcja hipergeometryczna, zamiast uogólnionej dystrybucji hipergeometrycznej. Przepraszam za to. – longread