# -*- coding: utf-8 -*- """ Created on Mon Oct 10 15:03:09 2011 @author: josef """ import numpy as np from scipy import stats np.set_printoptions(precision=4) print 'lognorm true' print 0.25, 0., 20.0 print 'estimated, floc=0, loc=0' for i in range(10): x = stats.lognorm.rvs(0.25, 0., 20.0, size=2000) print np.array(stats.lognorm.fit(x, floc=0.)), \ np.array(stats.lognorm.fit(x, loc=0.)) print 'gamma true' print 2, 20, 10.0 print 'estimated, floc=0, loc=0' for i in range(10): x = stats.gamma.rvs(2, 20, 10., size=2000) print np.array(stats.gamma.fit(x, floc=20)), \ np.array(stats.gamma.fit(x, loc=20)), \ np.array(stats.gamma.fit(x, loc=20, fscale=10)) print 'normal true' print 0., 2.0 print 'estimated, floc=0, loc=0, fscale=2' for i in range(10): x = stats.norm.rvs(0., 2., size=2000) print np.array(stats.norm.fit(x, floc=0)), \ np.array(stats.norm.fit(x, loc=0)), \ np.array(stats.norm.fit(x, fscale=2)) print 'chi2 true' shape, loc, scale = 10, 0., 2.0 print shape, loc, scale print 'estimated, floc=0, loc=0' distr = stats.chi2 for i in range(10): x = distr.rvs(shape, loc, scale, size=2000) print np.array(distr.fit(x, floc=0)), \ np.array(distr.fit(x, loc=0)) ''' true 0.25 0.0 20.0 estimated, floc=0, loc=0 [ 2.1271 0. 2.3999] [ 0.2623 1.0211 18.7911] [ 2.1393 0. 2.3952] [ 0.2523 0.0294 20.0117] [ 2.1356 0. 2.3978] [ 0.2477 0.03 19.9703] [ 2.1378 0. 2.3874] [ 0.2496 0.0301 19.9231] [ 2.1463 0. 2.3641] [ 0.2474 0.0292 19.9051] [ 2.1408 0. 2.3898] [ 0.2459 0.0303 20.0118] [ 2.1252 0. 2.4326] [ 0.251 0.029 20.0412] [ 2.1296 0. 2.3943] [ 0.2476 0.0296 19.8208] [ 2.1344 0. 2.401 ] [ 0.2472 0.0299 19.9744] [ 2.1383 0. 2.4133] [ 0.247 0.0301 20.1544] '''