corina.cross
Class Cross

java.lang.Object
  |
  +--corina.cross.Cross
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
DScore, NeuralD, Trend, TScore, Weiserjahre

public abstract class Cross
extends Object
implements Runnable

Abstract class representing the scores of a crossdate. The data vector holds the crossdate scores; the range holds the range of end dates for the moving sample. After construction, the run() method must be called; making this a good candidate for running in a thread.

Instead of an abstract class, this might be better off as an interface (extends Runnable) with a couple of public accessor methods. I can still provide an abstract class that implements this interface, like Swing does in many places.

Version:
$Id: Cross.java,v 1.3 2002/10/29 17:07:30 bitpoet Exp $
Author:
Ken Harris

Field Summary
 double[] data
          The crossdate scores.
protected  Sample fixed
          Reference to the sample being held fixed.
 List highScores
          A vector of high (statistically significant) scores.
protected  Sample moving
          Reference to the sample being moved to compute the vector of scores.
static ResourceBundle msg
          Resource bundle for localization.
 
Constructor Summary
protected Cross()
           
  Cross(Sample fixed, Sample moving)
          Create a crossdate, given fixed and moving samples.
 
Method Summary
abstract  double compute(int offset_fixed, int offset_moving)
          Compute an individual score, starting at the given offsets into the fixed and moving samples.
 Sample getFixed()
          Returns the fixed sample.
abstract  String getFormat()
          Return a format string for this cross to be used with DecimalFormat.
static int getMinimumOverlap()
          The minimum allowable crossdate overlap between two samples; its value is 15.
abstract  double getMinimumSignificant()
           
 Sample getMoving()
          Returns the moving sample.
abstract  String getName()
          Return a human-readable name for the crossdate.
 boolean isFinished()
          Is the run finished?
abstract  boolean isSignificant(double score, int overlap)
           
protected  void preamble()
          Crossdate preamble: any setup that needs to be done before the main loop to compute individual scores.
 void run()
          Run the crossdate.
 float single()
          Run a single crossdate on the (absolutely-dated) samples.
 String toString()
          Return the cross as a String, in the format "Cross: SampleA versus SampleB".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

msg

public static ResourceBundle msg
Resource bundle for localization.

data

public double[] data
The crossdate scores.

fixed

protected Sample fixed
Reference to the sample being held fixed.

moving

protected Sample moving
Reference to the sample being moved to compute the vector of scores.

highScores

public List highScores
A vector of high (statistically significant) scores. A vector of Integer indices into the data. The (private) method computeHighScores() computes this, and should be called in run() after the scores have been computed, but before finished is set.
Constructor Detail

Cross

protected Cross()

Cross

public Cross(Sample fixed,
             Sample moving)
Create a crossdate, given fixed and moving samples.
Parameters:
fixed - sample to hold fixed
moving - sample to compare against the fixed sample
Method Detail

getFixed

public Sample getFixed()
Returns the fixed sample.
Returns:
the fixed sample

getMoving

public Sample getMoving()
Returns the moving sample.
Returns:
the moving sample

isFinished

public boolean isFinished()
Is the run finished?

getMinimumOverlap

public static int getMinimumOverlap()
The minimum allowable crossdate overlap between two samples; its value is 15.

getName

public abstract String getName()
Return a human-readable name for the crossdate.
Returns:
a user-readable name for this type of cross

getFormat

public abstract String getFormat()
Return a format string for this cross to be used with DecimalFormat.
Returns:
a format string for this cross

toString

public final String toString()
Return the cross as a String, in the format "Cross: SampleA versus SampleB".
Overrides:
toString in class Object
Returns:
a String value of the cross

isSignificant

public abstract boolean isSignificant(double score,
                                      int overlap)

getMinimumSignificant

public abstract double getMinimumSignificant()

preamble

protected void preamble()
Crossdate preamble: any setup that needs to be done before the main loop to compute individual scores.

compute

public abstract double compute(int offset_fixed,
                               int offset_moving)
Compute an individual score, starting at the given offsets into the fixed and moving samples. (One of the offsets will always be zero, so you never need to look backwards in the data.)
Parameters:
offset_fixed - index of the fixed data to start at
offset_moving - index of the moving data to start at
Returns:
score at this position

run

public final void run()
Run the crossdate. Calls the preamble, and loops to compute the scores.
Specified by:
run in interface Runnable
See Also:
preamble(), compute(int, int)

single

public float single()
Run a single crossdate on the (absolutely-dated) samples. Member highScores remains empty, and finished remains false. The offsets are derived from the dates of the samples, which are assumed to be absolutely dated.
Returns:
the crossdate score between the samples at their saved positions