#NEWLINE# def test_fix_fit_gamma( self ) : #NEWLINE# #INDENT# x = np . arange ( 1 , 6 ) #NEWLINE# meanlog = np . log ( x ) . mean ( ) #NEWLINE# floc = 0 #NEWLINE# ( a , loc , scale ) = stats . gamma . fit ( x , floc = floc ) #NEWLINE# s = ( np . log ( x . mean ( ) ) - meanlog ) #NEWLINE# assert_almost_equal ( ( np . log ( a ) - special . digamma ( a ) ) , s , decimal = 5 ) #NEWLINE# assert_equal ( loc , floc ) #NEWLINE# assert_almost_equal ( scale , ( x . mean ( ) / a ) , decimal = 8 ) #NEWLINE# f0 = 1 #NEWLINE# floc = 0 #NEWLINE# ( a , loc , scale ) = stats . gamma . fit ( x , f0 = f0 , floc = floc ) #NEWLINE# assert_equal ( a , f0 ) #NEWLINE# assert_equal ( loc , meanlog ) #NEWLINE# assert_almost_equal ( scale , ( x . mean ( ) / a ) , decimal = 8 ) #NEWLINE# f0 = 2 #NEWLINE# floc = 0 #NEWLINE# ( a , loc , scale ) = stats . gamma . fit ( x , f0 = f0 , floc = floc ) #NEWLINE# assert_equal ( a , f0 ) #NEWLINE# assert_equal ( loc , floc ) #NEWLINE# assert_almost_equal ( scale , ( x . mean ( ) / a ) , decimal = 8 ) #NEWLINE# floc = 0 #NEWLINE# fscale = 2 #NEWLINE# ( a , loc , scale ) = stats . gamma . fit ( x , floc = floc , fscale = fscale ) #NEWLINE# assert_equal ( loc , floc ) #NEWLINE# assert_equal ( scale , fscale ) #NEWLINE# c = ( meanlog - np . log ( fscale ) ) #NEWLINE# assert_almost_equal ( special . digamma ( a ) , c )