 |
Calculate eecentricity using a principle component analysis (PCA)
Source code name: "stat_eecentricity.py"
Programming language: Python
Topic: Statistics/Advanced
DMelt Version 1. Last modified: 12/11/2015. License: Pro
https://datamelt.org/code/cache/stat_eecentricity_4323.py
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
# Eccentricity is defined as 1- variance(minor)/variance(major)
from jhplot import *
from java.util import Random
c1 = HPlot("Canvas",600,400)
c1.setNameX("Xaxis")
c1.setNameY("Yaxis")
c1.visible(1)
c1.setRange(-4,4,-4,4)
p1 = P1D("Data")
rand = Random();
for i in range(5000):
p1.add(rand.nextGaussian(),0.5*rand.nextGaussian())
c1.draw(p1);
# principle component analysis
from jhpro.stat import EEcentricity
pca=EEcentricity(p1)
print " Min variance=", pca.getVarianceMin(), "Max variance=", pca.getVarianceMax()
print "EECentricity=" ,pca.getEccentricity()
You see the box below because you did not login.