Library / Code module
Dithered sign expectation and its inverse
dithered_sign_expectation
Compute the mean of sign(x + noise) for Gaussian or uniform dither, 2 Phi(x/sigma) - 1 or x/a, check it against a seeded Monte Carlo estimate with its standard error, and invert it to recover x from an observed mean of one-bit readings.
ATTRIBUTION.md3.9 KBLICENSE1.0 KBREADME.md2.6 KBatom_cli.py3.0 KBcomponent.json7.7 KBdithered_sign_expectation.py3.8 KBnumerics.py28.0 KBschema_lite.py8.9 KBtest_dithered_sign_expectation.py2.5 KBtest_package.py12.0 KB
Full files in your harness.
What it takes and gives
- Runs with
- Python 3.10 or later
- Entry points
- sign_expectation, monte_carlo_sign_expectation, recover_offset
- Known answers
- 10 cases its tests reproduce
Cases it covers
- not the undithered sign: Without dither the mean sign is 1 for every positive x and the magnitude is lost.
- not the small signal slope: Extrapolating the slope sqrt(2/pi) at zero overstates the mean once x is comparable to sigma.
Limits and scope
- Limits
- Gaussian and uniform dither only, with a known scale. Inversion of the Gaussian form needs a mean strictly inside (-1, 1) and loses precision near the ends, where the curve is flat. The Monte Carlo check uses a Box-Muller generator on random() and is a consistency check, not a proof.
- Guarantees
- Gaussian: E[sign(x + sigma Z)] = 2 Phi(x / sigma) - 1, computed as erf(x / (sigma sqrt 2)). Uniform on [-a, a]: x / a inside [-a, a], sign(x) outside. recover_offset inverts sign_expectation; the Monte Carlo standard error is sqrt((1 - m^2) / N).
- Assumes
- The dither is independent of x and of the other draws, with the stated distribution and scale. sign(0) = 0; with continuous dither this happens with probability 0.
Details
- Kind
- Code module
- Licence
- MIT
- Declared effects
- runs commands
- Source
- github.com/alisonjieli-png/loop-engine/tools/creative_originals/evaluation_atoms/items/dithered_sign_expectation
- Size
- 10 files, 73.4 KB
- Identity
library.supply.creative_originals.0468786c2ae2e0134b0e3e62.48018416d96a426a- Version
48018416d96a426a1baa17aae344c6d8ad1ae0dda488095bad5b67eb3d6e4c13
The version is the SHA-256 of the item your harness downloads; every file in it names its own checksum.
Where it is shown
- Statistics for comparing resultsDeterministic skills
Related components
Something wrong with this item, its rights or its safety? Report it on the support page, or from your harness after a download.