Class pmr.stat.Bivariate
All Packages Class Hierarchy This Package Previous Next Index
Class pmr.stat.Bivariate
java.lang.Object

+pmr.stat.Stat

+pmr.stat.DrawableStat

+pmr.stat.Bivariate
 public class Bivariate
 extends DrawableStat
Bivariate  Bivariate class
This class holds two RealArrays/Univariates of equal length (x and y)
and returns statistical calculations (correlation coefficient, slopes
regression lines, etc) on them. It is also possible to display() Bivariates
as graphs, scatterpplots, etc.
Points can be added to the distributions and as soon as there are 2 or more,
the object becomes valid.
 Author:
 P.MurrayRust 1996, (C) P. MurrayRust, 1996

BAR


GRAPH


LINE


numdata
 number of data

points
 hold as a Real2Vector if required (e.g.

SCATTERPLOT
 display switches

Bivariate()
 creates it with default data arrays

Bivariate(RealArray)
 form a Bivariate from a RealArray.

Bivariate(Univariate)
 form a Bivariate from a Univariate.

Bivariate(Univariate, Univariate)
 form a Bivariate from two Univariates.

addElement(double, double)
 add a point; this is possible whether 'this' is initilised or not

debug()


display(Graphics)
 used by the ScrollableTopLevel to paint the object, or can be used to
draw the object to somewhere else.

display(Graphics, Component)
 this may encapsulate the above routine, as we often need the component, e.g.

display(Graphics, Scaler2D)
 normally called from an object which otherwise uses Scaler2D, but
wants to reroute graphics through Bivariate

displayBoundingBox(boolean)


displayXAxis(boolean)


displayYAxis(boolean)


dotPlot(Bivariate, double)
 do a dotplot of two Bivariates.

elementAt(int)


getCorrelationCoefficient()


getCurrentIndexes()
 get indices of all points within current bounding box

getInterceptXonY()
 get intercept when X regressed on Y

getInterceptYonX()
 get intercept when Y regressed on X

getMeanX()


getMeanY()


getRangeX()


getRangeXY()


getRangeY()


getScaler2D()
 get the Scaler2D context (allows 2D scaling, etc)
May reorganise this later...

getSelectedItem(int, int)
 the click may come from another object  horrors  and this kludge tries
to interpret it

getSlopeXonY()
 get slope when X regressed on Y

getSlopeYonX()
 get slope when Y regressed on X

getStandardDeviationX()


getStandardDeviationY()


getTitle()


getX()


getY()


labelPoints(boolean)


main(String[])


mouseBox(Event, IntRange, IntRange)


mouseUp(Event, int, int)
 action when mouse is unclicked; if not overridden, no action

pickBar(double)


process()


setDisplayType(int)


setHighlight(IntSet)


setIsometric(boolean)


setTitle(String)
 set a title.

setXTitle(String)


setYTitle(String)


size()


toString()

SCATTERPLOT
public final static int SCATTERPLOT
 display switches
GRAPH
public final static int GRAPH
LINE
public final static int LINE
BAR
public final static int BAR
numdata
protected int numdata
 number of data
points
protected Real2Vector points
 hold as a Real2Vector if required (e.g. for plot)
Bivariate
public Bivariate()
 creates it with default data arrays
Bivariate
public Bivariate(Univariate x,
Univariate y) throws UnequalLengthArraysException
 form a Bivariate from two Univariates. (Univariate can be formed from
double[] or RealArray if required).
 Throws: UnequalLengthArraysException
 Univariates are of different sizes
Bivariate
public Bivariate(Univariate y)
 form a Bivariate from a Univariate. In this case the xvariate is
assumed to run from 1...ndata
Bivariate
public Bivariate(RealArray y)
 form a Bivariate from a RealArray. In this case the xvariate is
assumed to run from 1...ndata
addElement
public void addElement(double x,
double y)
 add a point; this is possible whether 'this' is initilised or not
size
public int size()
getX
public Univariate getX()
getY
public Univariate getY()
elementAt
public Real2 elementAt(int i)
getStandardDeviationX
public double getStandardDeviationX() throws ArrayTooSmallException
 Throws: ArrayTooSmallException
 must have at least 2 point to calculate standard deviation
getMeanX
public double getMeanX() throws ArrayTooSmallException
 Throws: ArrayTooSmallException
 must have at least 1 point to calculate mean
getRangeX
public RealRange getRangeX() throws ArrayTooSmallException
 Throws: ArrayTooSmallException
 must have at least 2 point to calculate range
getStandardDeviationY
public double getStandardDeviationY() throws ArrayTooSmallException
 Throws: ArrayTooSmallException
 must have at least 2 point to calculate standard deviation
getMeanY
public double getMeanY() throws ArrayTooSmallException
 Throws: ArrayTooSmallException
 must have at least 1 point to calculate mean
getRangeY
public RealRange getRangeY() throws ArrayTooSmallException
 Throws: ArrayTooSmallException
 must have at least 2 point to calculate range
getRangeXY
public Real2Range getRangeXY() throws ArrayTooSmallException
 Throws: ArrayTooSmallException
 must have at least 2 point to calculate range
getCorrelationCoefficient
public double getCorrelationCoefficient() throws ArrayTooSmallException, CoincidentDataException
 Throws: ArrayTooSmallException
 must have at least 2 point to calculate regression
 Throws: CoincidentDataException
 must have 2 distinct points to calculate regression
getSlopeXonY
public double getSlopeXonY() throws ArrayTooSmallException, CoincidentDataException
 get slope when X regressed on Y
 Throws: ArrayTooSmallException
 must have at least 2 point to calculate regression
 Throws: CoincidentDataException
 must have 2 distinct points to calculate regression
getInterceptXonY
public double getInterceptXonY() throws ArrayTooSmallException, CoincidentDataException
 get intercept when X regressed on Y
 Throws: ArrayTooSmallException
 must have at least 2 point to calculate regression
 Throws: CoincidentDataException
 must have 2 distinct points to calculate regression
getSlopeYonX
public double getSlopeYonX() throws ArrayTooSmallException, CoincidentDataException
 get slope when Y regressed on X
 Throws: ArrayTooSmallException
 must have at least 2 point to calculate regression
 Throws: CoincidentDataException
 must have 2 distinct points to calculate regression
getInterceptYonX
public double getInterceptYonX() throws ArrayTooSmallException, CoincidentDataException
 get intercept when Y regressed on X
 Throws: ArrayTooSmallException
 must have at least 2 point to calculate regression
 Throws: CoincidentDataException
 must have 2 distinct points to calculate regression
process
public void process() throws ArrayTooSmallException, CoincidentDataException
 Throws: ArrayTooSmallException
 must have at least 2 points
 Throws: CoincidentDataException
 must have 2 distinct points
 Overrides:
 process in class Stat
setTitle
public void setTitle(String title)
 set a title.
 Overrides:
 setTitle in class DrawableStat
getTitle
public String getTitle()
 Overrides:
 getTitle in class Stat
setXTitle
public void setXTitle(String xt)
setYTitle
public void setYTitle(String yt)
setDisplayType
public void setDisplayType(int displayType)
setIsometric
public void setIsometric(boolean b)
displayXAxis
public void displayXAxis(boolean b)
displayYAxis
public void displayYAxis(boolean b)
displayBoundingBox
public void displayBoundingBox(boolean b)
labelPoints
public void labelPoints(boolean b)
display
public void display(Graphics g,
Scaler2D d)
 normally called from an object which otherwise uses Scaler2D, but
wants to reroute graphics through Bivariate
display
public void display(Graphics g)
 used by the ScrollableTopLevel to paint the object, or can be used to
draw the object to somewhere else.
 Overrides:
 display in class DrawableStat
display
public void display(Graphics g,
Component comp)
 this may encapsulate the above routine, as we often need the component, e.g.
 Overrides:
 display in class DrawableStat
getCurrentIndexes
public IntSet getCurrentIndexes()
 get indices of all points within current bounding box
toString
public String toString()
 Overrides:
 toString in class Object
dotPlot
public void dotPlot(Bivariate b,
double thresh) throws ArrayTooSmallException, CoincidentDataException
 do a dotplot of two Bivariates. EXPERIMENTAL!! Give a threshold
for the smallest peak allowed as a function of the maximum.
Assume the Xaxis is the scale for each bivariate...
 Throws: ArrayTooSmallException
 must have at least 2 points to calculate a dot plot
 Throws: CoincidentDataException
 must have at least 2 separated points to calculate a dot plot
getScaler2D
public Scaler2D getScaler2D()
 get the Scaler2D context (allows 2D scaling, etc)
May reorganise this later...
 Overrides:
 getScaler2D in class DrawableStat
mouseUp
public boolean mouseUp(Event evt,
int x,
int y)
 action when mouse is unclicked; if not overridden, no action
 Overrides:
 mouseUp in class DrawableStat
pickBar
public int pickBar(double xx)
getSelectedItem
public int getSelectedItem(int x,
int y)
 the click may come from another object  horrors  and this kludge tries
to interpret it
setHighlight
public void setHighlight(IntSet items)
mouseBox
public boolean mouseBox(Event evt,
IntRange xr,
IntRange yr)
debug
public void debug()
 Overrides:
 debug in class DrawableStat
main
public static void main(String args[])
All Packages Class Hierarchy This Package Previous Next Index