Skip to content

Commit

Permalink
moved distribution plots from test file to examples file (yet to be c…
Browse files Browse the repository at this point in the history
…ommitted
  • Loading branch information
gpanterov committed Jul 11, 2012
1 parent 398acf1 commit 8b14a1a
Showing 1 changed file with 1 addition and 114 deletions.
115 changes: 1 addition & 114 deletions statsmodels/nonparametric/tests/test_nonparametric2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import scipy.stats as stats
import statsmodels.nonparametric as nparam


class MyTest(object):
def setUp(self):
N = 60
Expand Down Expand Up @@ -85,8 +84,6 @@ def test_pdf_mixeddata_CV_ML(self):
dens_ml = nparam.UKDE(tdat=[self.c1, self.o, self.c2], var_type='coc',
bw='cv_ml')



def test_pdf_continuous(self):
# Test for only continuous data

Expand Down Expand Up @@ -120,116 +117,6 @@ def test_unordered_CV_LS(self):
npt.assert_allclose(dens.bw, R_result, atol = 1e-2)


def test_beta(self, a=2, b=5, N=250):
support = np.random.beta(a,b, size = N)
rv = stats.beta(a,b)
ix = np.argsort(support)

dens_normal = nparam.UKDE(tdat=[support], var_type='c', bw='normal_reference')
dens_cvls = nparam.UKDE(tdat=[support], var_type='c', bw='cv_ls')
dens_cvml = nparam.UKDE(tdat=[support], var_type='c', bw='cv_ml')
plt.plot(support[ix],rv.pdf(support[ix]), label='Actual')
plt.plot(support[ix],dens_normal.pdf()[ix],label='Scott')
plt.plot(support[ix],dens_cvls.pdf()[ix], label='CV_LS')
plt.plot(support[ix],dens_cvml.pdf()[ix], label='CV_ML')
plt.title("Nonparametric Estimation of the Density of Beta Distributed Random Variable")
plt.legend(('Actual','Scott','CV_LS','CV_ML'))
plt.show()

def test_f(self, df=100, dn=100, N=250):
support = np.random.f(dn,df, size = N)
rv = stats.f(df,dn)
ix = np.argsort(support)

dens_normal = nparam.UKDE(tdat=[support], var_type='c', bw='normal_reference')
dens_cvls = nparam.UKDE(tdat=[support], var_type='c', bw='cv_ls')
dens_cvml = nparam.UKDE(tdat=[support], var_type='c', bw='cv_ml')
plt.plot(support[ix],rv.pdf(support[ix]), label='Actual')
plt.plot(support[ix],dens_normal.pdf()[ix],label='Scott')
plt.plot(support[ix],dens_cvls.pdf()[ix], label='CV_LS')
plt.plot(support[ix],dens_cvml.pdf()[ix], label='CV_ML')
plt.title("Nonparametric Estimation of the Density of f Distributed Random Variable")
plt.legend(('Actual','Scott','CV_LS','CV_ML'))
plt.show()
def test_pareto(self, a=2, N=150):
support = np.random.pareto(a, size = N)
rv = stats.pareto(a)
ix = np.argsort(support)

dens_normal = nparam.UKDE(tdat=[support], var_type='c', bw='normal_reference')
dens_cvls = nparam.UKDE(tdat=[support], var_type='c', bw='cv_ls')
dens_cvml = nparam.UKDE(tdat=[support], var_type='c', bw='cv_ml')
plt.plot(support[ix],rv.pdf(support[ix]), label='Actual')
plt.plot(support[ix],dens_normal.pdf()[ix],label='Scott')
plt.plot(support[ix],dens_cvls.pdf()[ix], label='CV_LS')
plt.plot(support[ix],dens_cvml.pdf()[ix], label='CV_ML')
plt.title("Nonparametric Estimation of the Density of Pareto Distributed Random Variable")
plt.legend(('Actual','Scott','CV_LS','CV_ML'))
plt.show()

def test_laplace(self, mu=0, s=1, N=250):
support = np.random.laplace(mu, s, size = N)
rv = stats.laplace(mu, s)
ix = np.argsort(support)

dens_normal = nparam.UKDE(tdat=[support], var_type='c', bw='normal_reference')
dens_cvls = nparam.UKDE(tdat=[support], var_type='c', bw='cv_ls')
dens_cvml = nparam.UKDE(tdat=[support], var_type='c', bw='cv_ml')
plt.plot(support[ix],rv.pdf(support[ix]), label='Actual')
plt.plot(support[ix],dens_normal.pdf()[ix],label='Scott')
plt.plot(support[ix],dens_cvls.pdf()[ix], label='CV_LS')
plt.plot(support[ix],dens_cvml.pdf()[ix], label='CV_ML')
plt.title("Nonparametric Estimation of the Density of Laplace Distributed Random Variable")
plt.legend(('Actual','Scott','CV_LS','CV_ML'))
plt.show()

def test_weibull(self, a=1, N=250):
support = np.random.weibull(a, size = N)
rv = stats.weibull_min(a)

ix = np.argsort(support)
dens_normal = nparam.UKDE(tdat=[support], var_type='c', bw='normal_reference')
dens_cvls = nparam.UKDE(tdat=[support], var_type='c', bw='cv_ls')
dens_cvml = nparam.UKDE(tdat=[support], var_type='c', bw='cv_ml')
plt.plot(support[ix],rv.pdf(support[ix]), label='Actual')
plt.plot(support[ix],dens_normal.pdf()[ix],label='Scott')
plt.plot(support[ix],dens_cvls.pdf()[ix], label='CV_LS')
plt.plot(support[ix],dens_cvml.pdf()[ix], label='CV_ML')
plt.title("Nonparametric Estimation of the Density of Laplace Distributed Random Variable")
plt.legend(('Actual','Scott','CV_LS','CV_ML'))
plt.show()

def test_power(self, a=0.7, N=250):
support = np.random.power(a, size = N)
rv = stats.powerlaw(a)

ix = np.argsort(support)
dens_normal = nparam.UKDE(tdat=[support], var_type='c', bw='normal_reference')
dens_cvls = nparam.UKDE(tdat=[support], var_type='c', bw='cv_ls')
dens_cvml = nparam.UKDE(tdat=[support], var_type='c', bw='cv_ml')
plt.plot(support[ix],rv.pdf(support[ix]), label='Actual')
plt.plot(support[ix],dens_normal.pdf()[ix],label='Scott')
plt.plot(support[ix],dens_cvls.pdf()[ix], label='CV_LS')
plt.plot(support[ix],dens_cvml.pdf()[ix], label='CV_ML')
plt.title("Nonparametric Estimation of the Density of Power-law Distributed Random Variable")
plt.legend(('Actual','Scott','CV_LS','CV_ML'))
plt.show()

def test_poisson(self, a=2, N=250):
support = np.random.poisson(a, size = N)
rv = stats.poisson(a)

ix = np.argsort(support)
dens_normal = nparam.UKDE(tdat=[support], var_type='o', bw='normal_reference')
dens_cvls = nparam.UKDE(tdat=[support], var_type='o', bw='cv_ls')
dens_cvml = nparam.UKDE(tdat=[support], var_type='o', bw='cv_ml')
plt.plot(support[ix],rv.pmf(support[ix]), label='Actual')
plt.plot(support[ix],dens_normal.pdf()[ix],label='Scott')
plt.plot(support[ix],dens_cvls.pdf()[ix], label='CV_LS')
plt.plot(support[ix],dens_cvml.pdf()[ix], label='CV_ML')
plt.title("Nonparametric Estimation of the Density of Poisson Distributed Random Variable")
plt.legend(('Actual','Scott','CV_LS','CV_ML'))
plt.show()
def test_continuous_cdf(self,edat=None):
dens = nparam.UKDE (tdat = [self.Italy_gdp, self.growth], var_type = 'cc',
bw = 'cv_ml')
Expand Down Expand Up @@ -262,7 +149,7 @@ def test_unordered_CV_LS (self):
dep_type='u',indep_type='c',bw='cv_ls')
print dens_ls.bw
print "Test completed"
#not a good match. needs more work



def test_pdf_continuous(self):
Expand Down

0 comments on commit 8b14a1a

Please sign in to comment.