scipy.special.gammasgn#
- scipy.special.gammasgn(x, out=None) = <ufunc 'gammasgn'>#
Vorzeichen der Gammafunktion.
Sie ist definiert als
\[\begin{split}\text{gammasgn}(x) = \begin{cases} +1 & \Gamma(x) > 0 \\ -1 & \Gamma(x) < 0 \end{cases}\end{split}\]wobei \(\Gamma\) die Gammafunktion ist; siehe
gamma. Diese Definition ist vollständig, da die Gammafunktion niemals Null ist; siehe die Diskussion nach [dlmf].- Parameter:
- xarray_like
Reeller Argument
- outndarray, optional
Optionales Ausgabe-Array für die Funktionswerte
- Rückgabe:
- skalar oder ndarray
Vorzeichen der Gammafunktion
Siehe auch
Hinweise
Die Gammafunktion kann berechnet werden als
gammasgn(x) * np.exp(gammaln(x)).Referenzen
[dlmf]NIST Digital Library of Mathematical Functions https://dlmf.nist.gov/5.2#E1
Beispiele
>>> import numpy as np >>> import scipy.special as sc
Es ist 1 für
x > 0.>>> sc.gammasgn([1, 2, 3, 4]) array([1., 1., 1., 1.])
Es wechselt zwischen -1 und 1 für negative ganze Zahlen.
>>> sc.gammasgn([-0.5, -1.5, -2.5, -3.5]) array([-1., 1., -1., 1.])
Es kann verwendet werden, um die Gammafunktion zu berechnen.
>>> x = [1.5, 0.5, -0.5, -1.5] >>> sc.gammasgn(x) * np.exp(sc.gammaln(x)) array([ 0.88622693, 1.77245385, -3.5449077 , 2.3632718 ]) >>> sc.gamma(x) array([ 0.88622693, 1.77245385, -3.5449077 , 2.3632718 ])