21
21
'qnwsimp' , 'qnwtrap' , 'qnwunif' , 'quadrect' , 'qnwbeta' ,
22
22
'qnwgamma' ]
23
23
24
+
24
25
@vectorize (nopython = True )
25
26
def gammaln (x ):
26
27
return math .lgamma (x )
@@ -681,6 +682,7 @@ def _make_multidim_func(one_d_func, n, *args):
681
682
nodes = gridmake (* nodes )
682
683
return nodes , weights
683
684
685
+
684
686
@jit (nopython = True )
685
687
def _qnwcheb1 (n , a , b ):
686
688
"""
@@ -729,6 +731,7 @@ def _qnwcheb1(n, a, b):
729
731
730
732
return nodes , weights
731
733
734
+
732
735
@jit (nopython = True )
733
736
def _qnwlege1 (n , a , b ):
734
737
"""
@@ -784,9 +787,10 @@ def _qnwlege1(n, a, b):
784
787
p2 = p1
785
788
p1 = ((2 * j - 1 ) * z * p2 - (j - 1 ) * p3 ) / j
786
789
790
+ # https://github.com/QuantEcon/QuantEcon.py/issues/530
787
791
top = n * (z * p1 - p2 )
788
792
bottom = z ** 2 - 1.0
789
- pp = top / bottom # https://github.com/QuantEcon/QuantEcon.py/issues/530
793
+ pp = top / bottom
790
794
z1 = z .copy ()
791
795
z = z1 - p1 / pp
792
796
if np .all (np .abs (z - z1 ) < 1e-14 ):
@@ -804,6 +808,7 @@ def _qnwlege1(n, a, b):
804
808
805
809
return nodes , weights
806
810
811
+
807
812
@jit (nopython = True )
808
813
def _qnwnorm1 (n ):
809
814
"""
@@ -882,6 +887,7 @@ def _qnwnorm1(n):
882
887
883
888
return nodes , weights
884
889
890
+
885
891
@jit (nopython = True )
886
892
def _qnwsimp1 (n , a , b ):
887
893
"""
@@ -930,6 +936,7 @@ def _qnwsimp1(n, a, b):
930
936
931
937
return nodes , weights
932
938
939
+
933
940
@jit (nopython = True )
934
941
def _qnwtrap1 (n , a , b ):
935
942
"""
@@ -977,6 +984,7 @@ def _qnwtrap1(n, a, b):
977
984
978
985
return nodes , weights
979
986
987
+
980
988
@jit (nopython = True )
981
989
def _qnwbeta1 (n , a = 1.0 , b = 1.0 ):
982
990
"""
@@ -1093,13 +1101,14 @@ def _qnwbeta1(n, a=1.0, b=1.0):
1093
1101
weights [i ] = temp / (pp * p2 )
1094
1102
1095
1103
nodes = (1 - nodes )/ 2
1096
- weights = weights * math .exp (gammaln (a + n ) + gammaln (b + n )
1097
- - gammaln (n + 1 ) - gammaln (n + ab + 1 ))
1098
- weights = weights / (2 * math .exp (gammaln (a + 1 ) + gammaln (b + 1 )
1099
- - gammaln (ab + 2 )))
1104
+ weights = weights * math .exp (gammaln (a + n ) + gammaln (b + n ) -
1105
+ gammaln (n + 1 ) - gammaln (n + ab + 1 ))
1106
+ weights = weights / (2 * math .exp (gammaln (a + 1 ) + gammaln (b + 1 ) -
1107
+ gammaln (ab + 2 )))
1100
1108
1101
1109
return nodes , weights
1102
1110
1111
+
1103
1112
@jit (nopython = True )
1104
1113
def _qnwgamma1 (n , a = 1.0 , b = 1.0 , tol = 3e-14 ):
1105
1114
"""
0 commit comments