You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--stats pushed the raw-space mean and stdDev through each column's display transform (exp for scale, sigmoid for opacity, the f_dc color transform). That only works for order statistics, so for these columns the reported mean and spread were wrong. For example, raw scales [0, ln 4] showed a mean of exp(mean) = 2 instead of 2.5, and a constant log-scale column showed a stdDev of exp(0) = 1 instead of 0.
StatsAccumulator now also computes a running mean and variance of the transformed values (Welford), exposed as displayMean and displayStdDev on LodStatsData and rounded to 6 significant digits. The running values are kept in units of an exact power-of-two scale, so squared deviations can't overflow while the values are finite; Infinity is reported only when a display value itself overflows (e.g. exp of a very large log-scale). The text table and JSON use them directly, and the JSON reports them as mean and stdDev, so the JSON shape doesn't change. Min, max and median still go through the transform, which is exact because the transforms are monotonic.
Adds tests comparing display-space mean and stdDev with exact values for opacity, scale, f_dc and x, covering the constant-column, overflow, near-overflow (raw scales 699/700) and arithmetic-mean cases.
Initialize scaling from nonzero display magnitude to prevent underflow
src/lib/ops/stats.ts:166
The scaling only grows from 1, so tiny finite display values can still underflow during the Welford product. For example, raw scales [-700, -699] transform to finite values, but this code reports displayStdDev = 0 instead of about 8.47e-305. Seed the scale from the first nonzero display magnitude, then continue growing it, so the accumulation protects against underflow as well as overflow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--statspushed the raw-space mean and stdDev through each column's display transform (expfor scale,sigmoidfor opacity, thef_dccolor transform). That only works for order statistics, so for these columns the reported mean and spread were wrong. For example, raw scales[0, ln 4]showed a mean ofexp(mean) = 2instead of 2.5, and a constant log-scale column showed a stdDev ofexp(0) = 1instead of0.StatsAccumulatornow also computes a running mean and variance of the transformed values (Welford), exposed asdisplayMeananddisplayStdDevonLodStatsDataand rounded to 6 significant digits. The running values are kept in units of an exact power-of-two scale, so squared deviations can't overflow while the values are finite;Infinityis reported only when a display value itself overflows (e.g.expof a very large log-scale). The text table and JSON use them directly, and the JSON reports them asmeanandstdDev, so the JSON shape doesn't change. Min, max and median still go through the transform, which is exact because the transforms are monotonic.Adds tests comparing display-space mean and stdDev with exact values for opacity, scale,
f_dcandx, covering the constant-column, overflow, near-overflow (raw scales 699/700) and arithmetic-mean cases.