sugr
Class Relation

java.lang.Object
  extended bysugr.Relation

public class Relation
extends java.lang.Object

class which contains methods to test two elements

Version:
1.1 (10.2.2003): - Fixed: getDistance() return t instead of return 0.0 - doTesting() changed so that computation of Testvalue t throws no matrix-dimension exception (but have a look on it if it's right, 1.1.1 (12.2.2003) - Changed: testValue() return the squareroot of t, just like Perl-sugr [relation.pm , line 208] 1.2 (16.2.2003)
- Fixed: corrected compute_PseudoInverse() (a trans() was too much) - Removed: compute_PseudoInverse() into linalg-classes (now matrix-method pseudoInverse() ) - Fixed: doTesting, calculation of t = d^t Sigma_dd^+ d now really used the pseudoInverse ;-) - Added: setAlpha_WithUsedDOF(double alpha) needs to remember the old used dof because the call in RelationApplet.java doesn't know the real dof - Fixed: chi2 was not actualized when a new alpha was set 1.3 (19.2.2003)
- Changed: Relation is from now on abstract. It shouldn't be possible to create a relation-instance, because it has no real relation (e.g. Point_2D/Point_2D + Equality) to test. Therefore it makes no sense to getDistance(), getalpha(), getChiČ() without any entities - Changed: compute_distance() is abstract. It should only be implemented in subclasses with know comparision and elements - Removed: testChiSquare (int dof): dof is now element of this class and does not need to be set exterior - changed: testChiSquare (double alpha, int dof) changed into testChiSquare (double alpha) - Removed: setAlpha_WithUsedDOF(...) because dof is now part of Relation - Changed: setAlpha(double _alpha) has functionality of removed method above - Changed: dof needs to be set and this is done in doTesting() because every subclass is calling this method (less work, you know ;-) - Changed: startvalue of alpha is set to 0.05 2.0 (17.06.2003, T. Laebe)
One part of the Relation is now BiRelationalProperty.

Author:
Norbert Fischer

Field Summary
protected  double alpha
           Represents significance niveau. this is a start value, you may change this
private static double C0
           Represents values for the chiČ-Test
private static double C1
           
private static double C2
           
protected  double chi2
           Represents the result of the chiČ-Test
protected  boolean condition
          If true, the entities are conditioned prior to the testing TODO: The conditioning does not work!
protected  Vector d
          Represents the non-squared, non-normalized test value.
private static double D1
           
private static double D2
           
private static double D3
           
private  BiRelationalProperty rprop
          The first part and the type of the relation.
private  Entity second
          The second part of the relation.
protected  Matrix Sigma
          Represents the covariance matrix of the non-squared, non-normalized test value d.
protected  double t
           Represents test value t = d^T %SIGMA_dd^+ d (see skript for more information)
 
Constructor Summary
Relation(BiRelationalProperty _rprop, Entity _second)
          Constructs a concrete relation.
Relation(BiRelationalProperty _rprop, Entity _second, boolean doConditioning)
          Constructs a concrete relation.
Relation(Entity _first, Entity _second, java.lang.Class relationType)
           Constructs a concrete relation.
Relation(Entity _first, Entity _second, java.lang.Class relationType, boolean doConditioning)
           Constructs a concrete relation.
 
Method Summary
private  void createRelationalProperty(Entity _first, java.lang.Class _second, java.lang.Class relationType)
          Create the relational property out of an entity and a relation type
 boolean decision()
           returns true if a relation between two elements (e.g l||m ) holds, and false if not
protected  void doTesting(boolean condition)
           This is the main routine. it tests two entities wether a given relation hold or not.
 double getAlpha()
           returns the significance niveau
static double getChiSquareDistributionValue(double _alpha, int dof)
           this calls the chiČ-routine.
 boolean getCondition()
          Return if conditioning is on.
 Vector getD()
           returns the non-squared, non-normalized test value
 Matrix getSigma()
           returns the covariance matrix of d
 void setAlpha(double _alpha)
           sets the significance niveau. must be between 0 and 1
 void setCondition(boolean doConditioning)
          Set whether conditioning should be done.
 double testThreshold()
           returns chiČ-testvalue
 double testValue()
           returns the testvalue t= d^t SIGMA_dd^+ d [see sugr-handbook p.17: "Statistically testing uncertain geometric relations", Ver2]
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rprop

private BiRelationalProperty rprop
The first part and the type of the relation.


second

private Entity second
The second part of the relation.


t

protected double t

Represents test value t = d^T %SIGMA_dd^+ d (see skript for more information)


C0

private static final double C0

Represents values for the chiČ-Test

See Also:
Constant Field Values

C1

private static final double C1
See Also:
Constant Field Values

C2

private static final double C2
See Also:
Constant Field Values

D1

private static final double D1
See Also:
Constant Field Values

D2

private static final double D2
See Also:
Constant Field Values

D3

private static final double D3
See Also:
Constant Field Values

chi2

protected double chi2

Represents the result of the chiČ-Test


alpha

protected double alpha

Represents significance niveau. this is a start value, you may change this


condition

protected boolean condition
If true, the entities are conditioned prior to the testing TODO: The conditioning does not work! It is turned off by default until the error is fixed!


d

protected Vector d
Represents the non-squared, non-normalized test value. This may be used for checking the sign of a scalar-valued test.


Sigma

protected Matrix Sigma
Represents the covariance matrix of the non-squared, non-normalized test value d.

Constructor Detail

Relation

public Relation(Entity _first,
                Entity _second,
                java.lang.Class relationType)
         throws java.lang.IllegalArgumentException

Constructs a concrete relation.

Parameters:
_first - the first entity of the relation

_second - the second entity of the relation

relationType - the type of the Relation (a derived class from BiRelationalProperty


Relation

public Relation(Entity _first,
                Entity _second,
                java.lang.Class relationType,
                boolean doConditioning)
         throws java.lang.IllegalArgumentException

Constructs a concrete relation.

Parameters:
_first - the first entity of the relation

_second - the second entity of the relation

relationType - the type of the Relation (a derived class from BiRelationalProperty
doConditioning - if true, conditioning is done.


Relation

public Relation(BiRelationalProperty _rprop,
                Entity _second)
Constructs a concrete relation.

Parameters:
_rprop - a relational property which consists of the first entity of the relation and (inclusivly) the type of the relation.
_second - the second entity of the relation

Relation

public Relation(BiRelationalProperty _rprop,
                Entity _second,
                boolean doConditioning)
Constructs a concrete relation.

Parameters:
_rprop - a relational property which consists of the first entity of the relation and (inclusivly) the type of the relation.
_second - the second entity of the relation
doConditioning - if true, conditioning is done.
Method Detail

decision

public boolean decision()

returns true if a relation between two elements (e.g l||m ) holds, and false if not

Returns:
a boolean with ...


testValue

public double testValue()

returns the testvalue t= d^t SIGMA_dd^+ d [see sugr-handbook p.17: "Statistically testing uncertain geometric relations", Ver2]


getChiSquareDistributionValue

public static double getChiSquareDistributionValue(double _alpha,
                                                   int dof)

this calls the chiČ-routine. Implemented after Stephan Heuels Perl:sugr [Basic.pm, line 686 ff]

Parameters:
_alpha - significance niveau
dof - degrees of freedom

Returns:
a double with ...


getAlpha

public double getAlpha()

returns the significance niveau

Returns:
a double with ...


setAlpha

public void setAlpha(double _alpha)

sets the significance niveau. must be between 0 and 1

Parameters:
_alpha - sets the new alpha-value


setCondition

public void setCondition(boolean doConditioning)
Set whether conditioning should be done.

Parameters:
doConditioning - if true, conditioning is done.

getCondition

public boolean getCondition()
Return if conditioning is on.

Returns:
true, if conditioning is on.

testThreshold

public double testThreshold()

returns chiČ-testvalue

Returns:
a double with ...


getD

public Vector getD()

returns the non-squared, non-normalized test value

Returns:
non-squared, non-normalized test value


getSigma

public Matrix getSigma()

returns the covariance matrix of d

Returns:
covariance matrix of d


doTesting

protected void doTesting(boolean condition)

This is the main routine. it tests two entities wether a given relation hold or not. This method should be called in every constructor of this class and of derived classes.


createRelationalProperty

private void createRelationalProperty(Entity _first,
                                      java.lang.Class _second,
                                      java.lang.Class relationType)
                               throws java.lang.IllegalArgumentException
Create the relational property out of an entity and a relation type

Parameters:
_first - Entity
_second - type of the second Entity.
relationType - the type of the relation.
Throws:
java.lang.IllegalArgumentException