def test_random_beta(): numpy.random.seed(0) x1 = activity.random('beta', alpha=2, beta=3, shape=(5, 2)) numpy.random.seed(0) x2 = numpy.random.beta(2, 3, size=(5, 2)) assert numpy.all((x1 - x2) < 0.0001)
def test_random_normal(): numpy.random.seed(0) x1 = activity.random('normal', mu=0, sigma=1, shape=(3, 4)) numpy.random.seed(0) x2 = numpy.random.normal(0, 1, size=(3, 4)) assert numpy.all((x1 - x2) < 0.0001)
def test_beta(self): numpy.random.seed(0) x1 = activity.random('beta', alpha=2, beta=3, shape=(5, 2)) numpy.random.seed(0) x2 = numpy.random.beta(2, 3, size=(5, 2)) nptest.assert_array_almost_equal(x1, x2)
def test_normal(self): numpy.random.seed(0) x1 = activity.random('normal', mu=0, sigma=1, shape=(3, 4)) numpy.random.seed(0) x2 = numpy.random.normal(0, 1, size=(3, 4)) nptest.assert_array_almost_equal(x1, x2)
def test_plot_fit(): # second fig2, ax2 = pyplot.subplots() norm_dist = dist.normal(μ=5.4, σ=2.5) data = activity.random('normal', μ=5.4, σ=2.5, shape=37) ax2 = activity.plot(norm_dist, ax=ax2, line_opts=dict(label='Theoretical PDF')) ax2 = activity.plot('normal', data=data, ax=ax2, line_opts=dict(label='Fit PDF')) ax2.legend()
def test_distplot_lognormal(): # fourth fig4, ax4 = pyplot.subplots() data = activity.random('lognormal', μ=0.75, σ=1.2, shape=125) logdata = numpy.log10(data) bins = numpy.logspace(logdata.min(), logdata.max(), num=30) distplot_opts = dict(rug=True, kde=False, norm_hist=True, bins=bins) line_opts = dict(color='firebrick', lw=3.5, label='Fit PDF') ax4 = activity.plot('lognormal', data=data, distplot=True, xscale='log', pad=0.01, ax=ax4, line_opts=line_opts, distplot_opts=distplot_opts)
def test_plot_pdf_fit(): # second fig2, ax2 = pyplot.subplots() norm_dist = dist.normal(μ=5.4, σ=2.5) data = activity.random('normal', μ=5.4, σ=2.5, shape=37) ax2 = activity.plot(norm_dist, ax=ax2, line_opts=dict(label='Theoretical PDF')) ax2 = activity.plot('normal', data=data, ax=ax2, line_opts=dict(label='Fit PDF')) ax2.legend() return fig2
def test_plot_distplot(): # third fig3, ax3 = pyplot.subplots() data = activity.random('normal', μ=5.4, σ=2.5, shape=37) ax3 = activity.plot('normal', data=data, distplot=True, ax=ax3) ax3.legend(loc='upper left')