Public Member Functions | |
DatasetError () | |
Default constructor. | |
DatasetError (Double plusminus, ErrorSource sourcetype, ErrorNorm normtype) | |
Constructor for symmetric error. | |
DatasetError (Double plus, Double minus, ErrorSource sourcetype, ErrorNorm normtype) | |
Constructor for asymmetric errors. | |
DatasetError (Dataset dataset, Double plusminus, ErrorSource sourcetype, ErrorNorm normtype) | |
Constructor for symmetric error, with attachment to parent Dataset. | |
DatasetError (Dataset dataset, Double plus, Double minus, ErrorSource sourcetype, ErrorNorm normtype) | |
Constructor for asymmetric errors, with attachment to parent Dataset. | |
Integer | getId () |
Get the dataset error ID. | |
DatasetError | setId (Integer datasetErrorId) |
Set the dataset error ID. | |
.hibernate.annotations.Parent Dataset | getDataset () |
Get the parent dataset. | |
DatasetError | setDataset (Dataset parentDataset) |
Set the parent dataset. | |
DatasetError | setNormType (ErrorNorm normtype) |
Set the error normalization type (abs, frac, pct, etc. | |
Uncertainty | setNormTypeString (String normtypeStr) throws HDException |
Try to set the error normalization type (abs, frac, pct, etc. | |
int | compareTo (DatasetError other) |
boolean | equals (Object other) |
Override equals method with business key equality. | |
int | hashCode () |
Override hashcode method. | |
boolean | isSymmetric () |
Are the plus and minus errors symmetric? | |
boolean | hasZeroSize () |
Are the plus and minus errors both zero? | |
Uncertainty | getAbsoluteError (Point p) throws HDException |
Calculate the absolute error object for this error and the given Point. | |
Double | getPlus () |
Get the upward error. | |
Uncertainty | setPlus (Double plus) |
Set the upward error. | |
Double | getMinus () |
Get the downward error. | |
Uncertainty | setMinus (Double minus) |
Set the downward error. | |
ErrorSource | getSourceType () |
Get the error source type (stat, sys, etc. | |
Uncertainty | setSourceType (ErrorSource sourcetype) |
Set the error source type (stat, sys, etc. | |
ErrorNorm | getNormType () |
Get the error normalization type (abs, frac, pct, etc. | |
String | getComment () |
Get the modification comment string. | |
Uncertainty | setComment (String comment) |
Set the modification comment string. | |
int | compareTo (Uncertainty other) |
String | toString () |
String representation. | |
String | toString (Integer indentBy) |
Indented string representation. | |
Package Functions | |
Logger | log () |
Neat method to allow every class to get hold of a custom-named Logger. |
as stored by a Dataset. These errors tend to be systematic and have relative normalisation, but this isn't necessarily the case.
Definition at line 16 of file DatasetError.java.
DatasetError | ( | ) |
DatasetError | ( | Double | plusminus, | |
ErrorSource | sourcetype, | |||
ErrorNorm | normtype | |||
) |
Constructor for symmetric error.
plusminus | : size of symmetric error | |
sourcetype | : origin of error, i.e. systematic, statistical, etc. | |
normtype | : normalisation of error, i.e. absolute, fractional, percentage, etc. |
Definition at line 38 of file DatasetError.java.
DatasetError | ( | Double | plus, | |
Double | minus, | |||
ErrorSource | sourcetype, | |||
ErrorNorm | normtype | |||
) |
Constructor for asymmetric errors.
plus | input < 0 gives -err1 | |
minus | input < 0 gives +err2 | |
sourcetype | : origin of error, i.e. systematic, statistical, etc. | |
normtype | : normalisation of error, i.e. absolute, fractional, percentage, etc. |
Definition at line 49 of file DatasetError.java.
DatasetError | ( | Dataset | dataset, | |
Double | plusminus, | |||
ErrorSource | sourcetype, | |||
ErrorNorm | normtype | |||
) |
Constructor for symmetric error, with attachment to parent Dataset.
plusminus | : size of symmetric error | |
sourcetype | : origin of error, i.e. systematic, statistical, etc. | |
normtype | : normalisation of error, i.e. absolute, fractional, percentage, etc. |
Definition at line 59 of file DatasetError.java.
References DatasetError.setDataset().
00059 { 00060 super(plusminus, sourcetype, normtype); 00061 setDataset(dataset); 00062 }
DatasetError | ( | Dataset | dataset, | |
Double | plus, | |||
Double | minus, | |||
ErrorSource | sourcetype, | |||
ErrorNorm | normtype | |||
) |
Constructor for asymmetric errors, with attachment to parent Dataset.
plus | input <0 gives -err1 | |
minus | input <0 gives +err2 | |
sourcetype | : origin of error, i.e. systematic, statistical, etc. | |
normtype | : normalisation of error, i.e. absolute, fractional, percentage, etc. |
Definition at line 71 of file DatasetError.java.
References DatasetError.setDataset().
00071 { 00072 super(plus, minus, sourcetype, normtype); 00073 setDataset(dataset); 00074 }
Integer getId | ( | ) |
Get the dataset error ID.
Definition at line 81 of file DatasetError.java.
Referenced by DatasetError.compareTo(), DatasetError.hashCode(), and DatasetError.setDataset().
DatasetError setId | ( | Integer | datasetErrorId | ) |
Set the dataset error ID.
Definition at line 86 of file DatasetError.java.
Referenced by DatasetError.setDataset().
.hibernate.annotations.Parent Dataset getDataset | ( | ) |
DatasetError setDataset | ( | Dataset | parentDataset | ) |
Set the parent dataset.
Definition at line 102 of file DatasetError.java.
References Dataset.getErrors(), DatasetError.getId(), Storeable.log(), and DatasetError.setId().
Referenced by Dataset.addError(), and DatasetError.DatasetError().
00102 { 00103 log().debug("Calling setDataset()"); 00104 _dataset = parentDataset; 00105 if (parentDataset != null) { 00106 if (getId() == null) { 00107 int highestId = 0; 00108 if (parentDataset.getErrors().size() > 0) { 00109 highestId = parentDataset.getErrors().last().getId(); 00110 } 00111 log().debug("Incrementing dataset error ID: " + (highestId + 1)); 00112 setId(highestId + 1); 00113 } 00114 parentDataset.getErrors().add(this); 00115 } 00116 return this; 00117 }
DatasetError setNormType | ( | ErrorNorm | normtype | ) |
Set the error normalization type (abs, frac, pct, etc.
) from the enum. Note that this method overrides the normal version from Uncertainty, since DatasetErrors cannot have absolute normalization. No exception is thrown because that would force a try block in general.
Reimplemented from Uncertainty.
Definition at line 131 of file DatasetError.java.
References Storeable.log(), and DatasetError.setNormType().
Referenced by DatasetError.setNormType(), and DatasetError.setNormTypeString().
00131 { 00132 if (normtype != ErrorNorm.ABS) { 00133 super.setNormType(normtype); 00134 } else { 00135 log().warn("Tried to set an absolute normalization on a DatasetError"); 00136 //throw new HDErrorNormException("Tried to set an absolute normalization on a DatasetError"); 00137 } 00138 return this; 00139 }
Uncertainty setNormTypeString | ( | String | normtypeStr | ) | throws HDException |
Try to set the error normalization type (abs, frac, pct, etc.
) from a String. Note that this method overrides the normal version from Uncertainty, since DatasetErrors cannot have absolute normalization.
Definition at line 148 of file DatasetError.java.
References DatasetError.setNormType().
00148 { 00149 try { 00150 ErrorNorm normtype = Enum.valueOf(ErrorNorm.class, normtypeStr.toUpperCase()); 00151 setNormType(normtype); 00152 } catch (IllegalArgumentException e) { 00153 throw new HDException(e); 00154 } 00155 return this; 00156 }
int compareTo | ( | DatasetError | other | ) |
Definition at line 162 of file DatasetError.java.
References DatasetError.getId(), and Storeable.log().
Referenced by Uncertainty.compareTo().
00162 { 00163 log().debug("Comparing dataset errors..."); 00164 if (getId() == null) { 00165 log().warn("Null dataset error ID"); 00166 return 1; // Sort null errors at the end 00167 } else if (getId() > other.getId()) { 00168 log().debug("Greater than"); 00169 return 1; 00170 } else if (getId() < other.getId()) { 00171 log().debug("Less than"); 00172 return -1; 00173 } else { 00174 log().debug("Equal to"); 00175 return 0; 00176 } 00177 }
boolean equals | ( | Object | other | ) |
Override equals method with business key equality.
Definition at line 184 of file DatasetError.java.
References DatasetError.hashCode().
00184 { 00185 if (this == other) return true; 00186 if (! (other instanceof DatasetError)) return false; 00187 return hashCode() == other.hashCode(); 00188 }
int hashCode | ( | ) |
Override hashcode method.
Definition at line 191 of file DatasetError.java.
References DatasetError.getId(), Uncertainty.getMinus(), Uncertainty.getNormType(), Uncertainty.getPlus(), and Uncertainty.getSourceType().
Referenced by DatasetError.equals().
00191 { 00192 int code = 29; 00193 if (getId() != null) code ^= getId().hashCode(); 00194 if (getSourceType() != null) code ^= getSourceType().hashCode(); 00195 if (getNormType() != null) code ^= getNormType().hashCode(); 00196 if (getPlus() != null) code ^= 2 * getPlus().hashCode(); // ensure this is even 00197 if (getMinus() != null) code ^= 2 * getMinus().hashCode(); // ensure this is even 00198 return code; 00199 }
boolean isSymmetric | ( | ) | [inherited] |
Are the plus and minus errors symmetric?
Definition at line 81 of file Uncertainty.java.
References Uncertainty.getMinus(), and Uncertainty.getPlus().
Referenced by Uncertainty.toString().
boolean hasZeroSize | ( | ) | [inherited] |
Are the plus and minus errors both zero?
Definition at line 87 of file Uncertainty.java.
References Uncertainty.getMinus(), and Uncertainty.getPlus().
Uncertainty getAbsoluteError | ( | Point | p | ) | throws HDException [inherited] |
Calculate the absolute error object for this error and the given Point.
Reimplemented in PointError.
Definition at line 98 of file Uncertainty.java.
References Uncertainty.getMinus(), Uncertainty.getNormType(), Uncertainty.getPlus(), Uncertainty.getSourceType(), and Uncertainty.Uncertainty().
Referenced by PointError.getAbsoluteError().
00098 { 00099 if (getNormType() == ErrorNorm.UNKNOWN) { 00100 throw new HDException("Attempted to get the absolute error from an unknown error type."); 00101 } 00102 00103 Double absplus = getPlus(); 00104 Double absminus = getMinus(); 00105 if (getNormType() != ErrorNorm.ABS) { 00106 if (getNormType() == ErrorNorm.FRAC) { 00107 absplus *= p.getValue(); 00108 absminus *= p.getValue(); 00109 } else if (getNormType() == ErrorNorm.PCT) { 00110 absplus *= (p.getValue() / 100.0); 00111 absminus *= (p.getValue() / 100.0); 00112 } 00113 } 00114 Uncertainty err = new Uncertainty(absplus, absminus, getSourceType(), ErrorNorm.ABS); 00115 return err; 00116 }
Double getPlus | ( | ) | [inherited] |
Get the upward error.
Definition at line 125 of file Uncertainty.java.
Referenced by Uncertainty.getAbsoluteError(), PointError.hashCode(), DatasetError.hashCode(), AxisError.hashCode(), Uncertainty.hasZeroSize(), Uncertainty.isSymmetric(), and Uncertainty.toString().
Uncertainty setPlus | ( | Double | plus | ) | [inherited] |
Set the upward error.
Definition at line 130 of file Uncertainty.java.
Referenced by Uncertainty.Uncertainty().
Double getMinus | ( | ) | [inherited] |
Get the downward error.
Definition at line 138 of file Uncertainty.java.
Referenced by Uncertainty.getAbsoluteError(), PointError.hashCode(), DatasetError.hashCode(), AxisError.hashCode(), Uncertainty.hasZeroSize(), Uncertainty.isSymmetric(), and Uncertainty.toString().
Uncertainty setMinus | ( | Double | minus | ) | [inherited] |
Set the downward error.
Definition at line 143 of file Uncertainty.java.
Referenced by Uncertainty.Uncertainty().
ErrorSource getSourceType | ( | ) | [inherited] |
Get the error source type (stat, sys, etc.
) as an enum.
Definition at line 151 of file Uncertainty.java.
Referenced by Uncertainty.getAbsoluteError(), PointError.hashCode(), DatasetError.hashCode(), AxisError.hashCode(), and Uncertainty.toString().
Uncertainty setSourceType | ( | ErrorSource | sourcetype | ) | [inherited] |
Set the error source type (stat, sys, etc.
) from the enum.
Definition at line 156 of file Uncertainty.java.
Referenced by Uncertainty.Uncertainty().
ErrorNorm getNormType | ( | ) | [inherited] |
Get the error normalization type (abs, frac, pct, etc.
) as an enum.
Definition at line 163 of file Uncertainty.java.
Referenced by Uncertainty.getAbsoluteError(), PointError.hashCode(), DatasetError.hashCode(), AxisError.hashCode(), and Uncertainty.toString().
String getComment | ( | ) | [inherited] |
Get the modification comment string.
Definition at line 174 of file Uncertainty.java.
Referenced by Uncertainty.toString().
Uncertainty setComment | ( | String | comment | ) | [inherited] |
int compareTo | ( | Uncertainty | other | ) | [inherited] |
Definition at line 187 of file Uncertainty.java.
References DatasetError.compareTo(), AxisError.compareTo(), PointError.compareTo(), and Storeable.log().
00187 { 00188 log().debug("Comparing errors..."); 00189 00190 // For point errors 00191 if (this instanceof PointError) { 00192 if (other instanceof PointError) { 00193 PointError test = (PointError) this; 00194 int result = test.compareTo((PointError) other); 00195 if (result != 0) return result; 00196 } else return 1; 00197 } 00198 00199 // For axis errors 00200 if (this instanceof AxisError) { 00201 if (other instanceof AxisError) { 00202 AxisError test = (AxisError) this; 00203 int result = test.compareTo((AxisError) other); 00204 if (result != 0) return result; 00205 } else return (other instanceof PointError) ? -1 : 1; 00206 } 00207 00208 // For dataset errors 00209 if (this instanceof DatasetError) { 00210 if (other instanceof DatasetError) { 00211 DatasetError test = (DatasetError) this; 00212 int result = test.compareTo((DatasetError) other); 00213 if (result != 0) return result; 00214 } else return 1; 00215 } 00216 00218 return 0; 00219 }
String toString | ( | ) | [inherited] |
String representation.
Reimplemented from Storeable.
Definition at line 227 of file Uncertainty.java.
Referenced by Uncertainty.toString().
00227 { 00228 return toString(0); 00229 }
String toString | ( | Integer | indentBy | ) | [inherited] |
Indented string representation.
Definition at line 233 of file Uncertainty.java.
References Uncertainty.getComment(), Uncertainty.getMinus(), Uncertainty.getNormType(), Uncertainty.getPlus(), Uncertainty.getSourceType(), Uncertainty.isSymmetric(), Storeable.log(), and Uncertainty.toString().
00233 { 00234 log().debug("Writing out error as a string"); 00235 StringBuffer s = new StringBuffer(); 00236 String indent = ""; 00237 for (int i = 0; i < indentBy; ++i) indent += " "; 00238 00239 //if (! hasZeroSize()) { 00240 s.append(indent); 00241 Double plusval = getPlus(); 00242 Double minusval = getMinus(); 00243 00244 String numFormat = "###.##"; 00245 // Use the number formatter to recalculate and display everything as a percentage 00246 if (getNormType() == ErrorNorm.PCT) { 00247 plusval /= 100; 00248 minusval /= 100; 00249 } 00250 if (getNormType() == ErrorNorm.FRAC || getNormType() == ErrorNorm.PCT) { 00251 numFormat += "%"; // multiplies by 100 and sticks "%" on the end 00252 } 00253 DecimalFormat numFormatter = new DecimalFormat(numFormat); 00254 if (isSymmetric()) { 00255 s.append("+- " + numFormatter.format(plusval)); 00256 } else { 00257 s.append("+ " + numFormatter.format(plusval)); 00258 s.append(" - " + numFormatter.format(minusval)); 00259 } 00260 s.append(" ("); 00261 //s.append(getNormType().toString()); 00262 //s.append(", "); 00263 s.append(getSourceType().toString()); 00264 s.append(")"); 00265 if (getComment() != null && getComment().length() != 0) { 00266 s.append(" [" + getComment() + "]"); 00267 } 00268 //} 00269 return s.toString(); 00270 }
Logger log | ( | ) | [package, inherited] |
Neat method to allow every class to get hold of a custom-named Logger.
Definition at line 14 of file Storeable.java.
Referenced by Uncertainty.compareTo(), Reference.compareTo(), PointError.compareTo(), Modification.compareTo(), Experiment.compareTo(), DatasetError.compareTo(), AxisError.compareTo(), Data.makeExample(), Data.makeExampleDataset(), Data.makeExampleExperiment(), Data.makeExamplePaper(), Data.makeExampleXAxes(), Data.makeExampleYAxes(), AxisError.setAxis(), DatasetError.setDataset(), DatasetError.setNormType(), PointError.setPoint(), and Uncertainty.toString().