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.Murray-Rust 1996, (C) P. Murray-Rust, 1996

Variable Index

 o BAR
 o GRAPH
 o LINE
 o numdata
number of data
 o points
hold as a Real2Vector if required (e.g.
 o SCATTERPLOT
display switches

Constructor Index

 o Bivariate()
creates it with default data arrays
 o Bivariate(RealArray)
form a Bivariate from a RealArray.
 o Bivariate(Univariate)
form a Bivariate from a Univariate.
 o Bivariate(Univariate, Univariate)
form a Bivariate from two Univariates.

Method Index

 o addElement(double, double)
add a point; this is possible whether 'this' is initilised or not
 o debug()
 o display(Graphics)
used by the ScrollableTopLevel to paint the object, or can be used to draw the object to somewhere else.
 o display(Graphics, Component)
this may encapsulate the above routine, as we often need the component, e.g.
 o display(Graphics, Scaler2D)
normally called from an object which otherwise uses Scaler2D, but wants to reroute graphics through Bivariate
 o displayBoundingBox(boolean)
 o displayXAxis(boolean)
 o displayYAxis(boolean)
 o dotPlot(Bivariate, double)
do a dot-plot of two Bivariates.
 o elementAt(int)
 o getCorrelationCoefficient()
 o getCurrentIndexes()
get indices of all points within current bounding box
 o getInterceptXonY()
get intercept when X regressed on Y
 o getInterceptYonX()
get intercept when Y regressed on X
 o getMeanX()
 o getMeanY()
 o getRangeX()
 o getRangeXY()
 o getRangeY()
 o getScaler2D()
get the Scaler2D context (allows 2D scaling, etc) May reorganise this later...
 o getSelectedItem(int, int)
the click may come from another object - horrors - and this kludge tries to interpret it
 o getSlopeXonY()
get slope when X regressed on Y
 o getSlopeYonX()
get slope when Y regressed on X
 o getStandardDeviationX()
 o getStandardDeviationY()
 o getTitle()
 o getX()
 o getY()
 o labelPoints(boolean)
 o main(String[])
 o mouseBox(Event, IntRange, IntRange)
 o mouseUp(Event, int, int)
action when mouse is unclicked; if not overridden, no action
 o pickBar(double)
 o process()
 o setDisplayType(int)
 o setHighlight(IntSet)
 o setIsometric(boolean)
 o setTitle(String)
set a title.
 o setXTitle(String)
 o setYTitle(String)
 o size()
 o toString()

Variables

 o SCATTERPLOT
  public final static int SCATTERPLOT
display switches
 o GRAPH
  public final static int GRAPH
 o LINE
  public final static int LINE
 o BAR
  public final static int BAR
 o numdata
  protected int numdata
number of data
 o points
  protected Real2Vector points
hold as a Real2Vector if required (e.g. for plot)

Constructors

 o Bivariate
  public Bivariate()
creates it with default data arrays
 o 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
 o Bivariate
  public Bivariate(Univariate y)
form a Bivariate from a Univariate. In this case the x-variate is assumed to run from 1...ndata
 o Bivariate
  public Bivariate(RealArray y)
form a Bivariate from a RealArray. In this case the x-variate is assumed to run from 1...ndata

Methods

 o addElement
  public void addElement(double x,
                         double y)
add a point; this is possible whether 'this' is initilised or not
 o size
  public int size()
 o getX
  public Univariate getX()
 o getY
  public Univariate getY()
 o elementAt
  public Real2 elementAt(int i)
 o getStandardDeviationX
  public double getStandardDeviationX() throws ArrayTooSmallException
Throws: ArrayTooSmallException
must have at least 2 point to calculate standard deviation
 o getMeanX
  public double getMeanX() throws ArrayTooSmallException
Throws: ArrayTooSmallException
must have at least 1 point to calculate mean
 o getRangeX
  public RealRange getRangeX() throws ArrayTooSmallException
Throws: ArrayTooSmallException
must have at least 2 point to calculate range
 o getStandardDeviationY
  public double getStandardDeviationY() throws ArrayTooSmallException
Throws: ArrayTooSmallException
must have at least 2 point to calculate standard deviation
 o getMeanY
  public double getMeanY() throws ArrayTooSmallException
Throws: ArrayTooSmallException
must have at least 1 point to calculate mean
 o getRangeY
  public RealRange getRangeY() throws ArrayTooSmallException
Throws: ArrayTooSmallException
must have at least 2 point to calculate range
 o getRangeXY
  public Real2Range getRangeXY() throws ArrayTooSmallException
Throws: ArrayTooSmallException
must have at least 2 point to calculate range
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o setTitle
  public void setTitle(String title)
set a title.
Overrides:
setTitle in class DrawableStat
 o getTitle
  public String getTitle()
Overrides:
getTitle in class Stat
 o setXTitle
  public void setXTitle(String xt)
 o setYTitle
  public void setYTitle(String yt)
 o setDisplayType
  public void setDisplayType(int displayType)
 o setIsometric
  public void setIsometric(boolean b)
 o displayXAxis
  public void displayXAxis(boolean b)
 o displayYAxis
  public void displayYAxis(boolean b)
 o displayBoundingBox
  public void displayBoundingBox(boolean b)
 o labelPoints
  public void labelPoints(boolean b)
 o display
  public void display(Graphics g,
                      Scaler2D d)
normally called from an object which otherwise uses Scaler2D, but wants to reroute graphics through Bivariate
 o 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
 o 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
 o getCurrentIndexes
  public IntSet getCurrentIndexes()
get indices of all points within current bounding box
 o toString
  public String toString()
Overrides:
toString in class Object
 o dotPlot
  public void dotPlot(Bivariate b,
                      double thresh) throws ArrayTooSmallException, CoincidentDataException
do a dot-plot of two Bivariates. EXPERIMENTAL!! Give a threshold for the smallest peak allowed as a function of the maximum. Assume the X-axis 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
 o getScaler2D
  public Scaler2D getScaler2D()
get the Scaler2D context (allows 2D scaling, etc) May reorganise this later...
Overrides:
getScaler2D in class DrawableStat
 o 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
 o pickBar
  public int pickBar(double xx)
 o getSelectedItem
  public int getSelectedItem(int x,
                             int y)
the click may come from another object - horrors - and this kludge tries to interpret it
 o setHighlight
  public void setHighlight(IntSet items)
 o mouseBox
  public boolean mouseBox(Event evt,
                          IntRange xr,
                          IntRange yr)
 o debug
  public void debug()
Overrides:
debug in class DrawableStat
 o main
  public static void main(String args[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index