Class RoundingUtils
Gemma's expression data descends from 16-bit measurements, and these are values that get plotted, not
values anything recomputes from. The digits this drops are also incompressible, which makes them costliest
exactly where the payload is largest: measured on gemma2, /datasets/1/mean-variance goes
from 883 KB to 346 KB decompressed, and from 382.6 KB to 101.0 KB gzipped. Say which of the two you mean
whenever you quote a size here — conflating them has already produced one wrong conclusion.
Significant digits, not decimal places: expression values, p-values and t-statistics span orders of
magnitude, and a p-value of 1e-300 has to survive. That rules out the Math.round(v * 1000) / 1000
shape used for the bounded [-1, 1] sample-correlation matrix.
This is the JSON counterpart of TsvUtils.format(double), which emits the same four significant
digits for every file writer. File output does not route through here.
- Author:
- paul
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAppliesround(double)at serialization time, leaving the in-memory value exact. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSignificant digits kept in JSON responses. -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleround(double v) Round toJSON_SIGNIFICANT_DIGITSsignificant digits.static DoubleNull-tolerantround(double), for boxed value-object fields.static double[]roundedCopy(double[] src) Round every element into a new array.static double[][]roundedCopy(double[][] src) Row-by-rowroundedCopy(double[]); see it for why this copies.
-
Field Details
-
JSON_SIGNIFICANT_DIGITS
public static final int JSON_SIGNIFICANT_DIGITSSignificant digits kept in JSON responses.- See Also:
-
-
Method Details
-
round
public static double round(double v) Round toJSON_SIGNIFICANT_DIGITSsignificant digits.NaN and the infinities are returned untouched: they have no
BigDecimalrepresentation, and the 0.0 that a naive rounding puts in their place reads as a measured zero rather than "not known". Signed zero keeps its sign. -
round
Null-tolerantround(double), for boxed value-object fields. -
roundedCopy
@Nullable public static double[] roundedCopy(@Nullable double[] src) Round every element into a new array.Copies rather than rounding in place: the arrays handed to value objects are frequently the loaded entity's or the cached matrix's own backing store, and rounding those corrupts what the next reader sees.
-
roundedCopy
@Nullable public static double[][] roundedCopy(@Nullable double[][] src) Row-by-rowroundedCopy(double[]); see it for why this copies.
-