Java Statistical Classes

jsc.swt.plot2d
Class CdfPlot

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--jsc.swt.plot2d.PlotPanel
                                |
                                +--jsc.swt.plot2d.AxesPlot
                                      |
                                      +--jsc.swt.plot2d.FunctionPlot2D
                                            |
                                            +--jsc.swt.plot2d.CdfPlot
All Implemented Interfaces:
Accessible, Cloneable, ImageObserver, MenuContainer, PlotFunction, Serializable

public class CdfPlot
extends FunctionPlot2D
implements PlotFunction, Cloneable

This class represents the plot of a cumulative distribution function (often simply called the distribution function). Methods are provided for adding any number of curves representing continuous or discrete distributions. Curves representing sample distribution functions and confidence bands can also be added to the plot.

The addStepFunction() method adds the curve of a general step function f(x) to the plot.

This plot is ideal for graphically representing a Kolmogorov type goodness-of-fit test.

Version:
1.0
Author:
A. J. Bertie.
See Also:
Serialized Form

Field Summary
 
Fields inherited from class jsc.swt.plot2d.AxesPlot
horizontalAxis, title, verticalAxis
 
Fields inherited from class jsc.swt.plot2d.PlotPanel
componentBounds, hints, objects, SEE_THRU, virtualSpace, vt
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
CdfPlot(String title, AxisModel X)
          Creates the plot with given title and X Axis object.
CdfPlot(String title, AxisModel X, AxisModel Y)
          Creates the plot with given title and Axis objects.
 
Method Summary
 PlotObject addCdf(Distribution F, double xMin, double xMax, int n, Color colour, Stroke stroke)
          Add the curve of cdf(x) of a continuous distribution to the plot.
 PlotObject addCdf(Distribution F, int xMin, int xMax, Color colour, Stroke stroke)
          Add the curve of cdf(x) of a discrete distribution to the plot.
 PlotObject[] addConfidenceBand(ConfidenceBand band, Color colour, Stroke stroke)
          Add curves representing a confidence band to the plot.
 PlotObject addSampleDistributionFunction(SampleDistributionFunction sdf, Color colour, Stroke stroke)
          Add the curve of a sample distribution function to the plot.
 PlotObject addStepFunction(double[] x, double[] f, boolean extendSteps, Color colour, Stroke stroke)
          Add the curve of a step function f(x) to the plot.
 Object clone()
          Clone the plot object.
 double getOrdinate(double x)
          Returns y = f(x).
 
Methods inherited from class jsc.swt.plot2d.FunctionPlot2D
addFunction, addFunction, addFunction, addFunction, addFunction, addFunction
 
Methods inherited from class jsc.swt.plot2d.AxesPlot
addVerticalLine, addVerticalLine, copy, getHorizontalAxis, getTitle, getVerticalAxis, outsideAxes, paintComponent, rescaleHorizontal, rescaleVertical, setClipping, setPaintXaxis, setPaintYaxis, setTitle
 
Methods inherited from class jsc.swt.plot2d.PlotPanel
addComponent, addComponent, addObject, addObjects, addRenderingHint, copyContents, copyPlot, ensureComponentCapacity, ensureObjectCapacity, getBufferedImage, getComponentBounds, getComponentBounds, getObject, getObject, getObjectCount, getObjectIndex, getObjects, getParHeight, getParWidth, getRenderingHints, getVirtualSpace, getVirtualTransform, isAntialiased, isEmpty, isTextAntialiased, merge, paintBackground, pixelToVirtual, pixelToVirtual, removeAll, removeAllComponents, removeAllObjects, removeComponent, removeLastComponent, removeLastObject, removeObject, removeObject, removeRenderingHint, setAntialiasing, setComponentBounds, setComponentBounds, setFocusColour, setObjectComposite, setTextAntialiasing, setVirtualSpace, setZoomable, setZoomBoxColour, setZoomBoxStroke, virtualToPixel, virtualToPixel, virtualToPixelHeight, virtualToPixelWidth, write, write
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CdfPlot

public CdfPlot(String title,
               AxisModel X)
Creates the plot with given title and X Axis object. The Y axis is labelled "CDF", extends from 0 to 1, with 11 tick marks at intervals of 0.1.

Parameters:
title - the title of the plot.
X - the horizontal axis.

CdfPlot

public CdfPlot(String title,
               AxisModel X,
               AxisModel Y)
Creates the plot with given title and Axis objects.

Parameters:
title - the title of the plot.
X - the horizontal axis.
Y - the vertical axis.
Method Detail

addCdf

public PlotObject addCdf(Distribution F,
                         double xMin,
                         double xMax,
                         int n,
                         Color colour,
                         Stroke stroke)
Add the curve of cdf(x) of a continuous distribution to the plot. The curve is plotted at n values of x from xMin to xMax using straight lines connecting the points, and the specified colour and stroke style.

Redraws the plot. Returns the PlotObject that was added to the plot.

Parameters:
F - a continuous distribution.
xMin - the minimum x value.
xMax - the maximum x value.
n - the number of points used to draw the curve.
colour - the colour of the curve.
stroke - the stroke style of the curve.
Returns:
the object added to the plot.

addCdf

public PlotObject addCdf(Distribution F,
                         int xMin,
                         int xMax,
                         Color colour,
                         Stroke stroke)
Add the curve of cdf(x) of a discrete distribution to the plot. The curve is plotted as a step function at each integer x values from xMin to xMax.

Redraws the plot. Returns the PlotObject that was added to the plot.

Parameters:
F - a continuous distribution.
xMin - the minimum x value.
xMax - the maximum x value.
colour - the colour of the curve.
stroke - the stroke style of the curve.
Returns:
the object added to the plot.

addConfidenceBand

public PlotObject[] addConfidenceBand(ConfidenceBand band,
                                      Color colour,
                                      Stroke stroke)
Add curves representing a confidence band to the plot. Typically this will be a confidence band for the distribution function centred around the sample distribution function. The curves are plotted as step functions. Note that if the confidence limits are less than 0 or greater than 1, it would be sensible to call setClipping(true).

Redraws the plot. Returns a PlotObject 2-element array referring to the two objects that were added to the plot: elements [0] and [1] refer to the lower and upper limit curves respectively.

Parameters:
band - the confidence band.
colour - the colour of the curve.
stroke - the stroke style of the curve.
Returns:
the array of objects added to the plot.

addSampleDistributionFunction

public PlotObject addSampleDistributionFunction(SampleDistributionFunction sdf,
                                                Color colour,
                                                Stroke stroke)
Add the curve of a sample distribution function to the plot.

Redraws the plot. Returns the PlotObject that was added to the plot.

Parameters:
sdf - the sample distribution function.
colour - the colour of the curve.
stroke - the stroke style of the curve.
Returns:
the object added to the plot.

addStepFunction

public PlotObject addStepFunction(double[] x,
                                  double[] f,
                                  boolean extendSteps,
                                  Color colour,
                                  Stroke stroke)
Add the curve of a step function f(x) to the plot. A step function is defined by an an array of function values y = f(x) at increasing discrete x values. The curve consists of a series of connected alternate horizontal and vertical straight lines. Horizontal lines are drawn from (x[i],y[i]) to (x[i+1],y[i]) and vertical lines from (x[i],y[i]) to (x[i],y[i+1]).

If extendSteps is true, a further vertical straight line is drawn from the first point to y = 0, and a further horizontal straight line is drawn from the last point to the maximum of the X-axis.

Redraws the plot. Returns the PlotObject that was added to the plot.

Parameters:
x - the ordered array of x values.
f - the corresponding array of f(x) values.
extendSteps - if true, first and last points are extended.
colour - the colour of the curve.
stroke - the stroke style of the curve.
Returns:
the object added to the plot.

clone

public Object clone()
Description copied from class: AxesPlot
Clone the plot object.

Overrides:
clone in class AxesPlot

getOrdinate

public double getOrdinate(double x)
Description copied from interface: PlotFunction
Returns y = f(x). The method should return Double.NaN if f(x) cannot be calculated at x.

Specified by:
getOrdinate in interface PlotFunction
Parameters:
x - the value of x.
Returns:
the value of f(x), or Double.NaN if f(x) does not exist.

Java Statistical Classes

Copyright © Andrew James Bertie, 2005, all rights reserved. Updated 12th Aug 2005