Example: stochastic rounding, as an operation with hidden randomness
Library · Source module
Example: stochastic rounding, as an operation with hidden randomness
At the level of an algorithm the stochastically rounded addition is srAdd [x, y] [z]: two operands, no random operand. Its contract (NLAlib.Ops.Examples.IsSrAdd, with the mathematics NLAlib.Ops.Examples.SrModel) is conditional on the history: the result is a function g of the two operands and of one entry of the tape that the operation reads for itself; for every pair of operands, over a fresh uniform draw, the result is within 2 u of the sum surely and has the sum as its mean.
Inside the implementation only, there is a primitive sraddXi [x, y, ξ] [z] that is given its random word: srAdd is implemented by "draw ξ into scratch; sraddXi". The scratch cell is freed at the end of the call; no cell of the algorithm ever holds ξ.
The algorithm is the stochastically rounded sum NLAlib.Ops.Examples.srsum.
Main results
* NLAlib.Ops.Examples.integral_dec_srsumF: the stochastically rounded sum is unbiased, 𝔼 ŝ = s, by the conditional law of each window given the past; with the sure bound NLAlib.Ops.Examples.abs_dec_srsumF_sub_le. Mathematics. * NLAlib.Ops.Examples.runsLaw_srsum: the abstract theorem, for every interpretation satisfying the contract of srAdd and every law of the tape: n calls, the workspace of one, the sure bound for every sample and 𝔼 ŝ = s. * NLAlib.Ops.Examples.sr_certifies: the certificate of the profile (contract by linking, counts, window by the window lemma). * NLAlib.Ops.Examples.runsLaw_srsum_link: the corollary for the program that draws, one application of Profile.Refines.runsLaw: n draws, n sraddXi, one scratch cell. * NLAlib.Ops.Examples.exists_isSrLo: the contracts can be met.
Declarations
- NLAlib.Ops.Examples.IsSrAdd
- NLAlib.Ops.Examples.IsSrLo
- NLAlib.Ops.Examples.SrLo
- NLAlib.Ops.Examples.SrLo.ofNat
- NLAlib.Ops.Examples.SrLo.ofNat_ctorIdx
- NLAlib.Ops.Examples.SrModel
- NLAlib.Ops.Examples.SrOp
- NLAlib.Ops.Examples.SrOp.ofNat
- NLAlib.Ops.Examples.SrOp.ofNat_ctorIdx
- NLAlib.Ops.Examples.SrsumPost
- NLAlib.Ops.Examples.abs_dec_srsumF_sub_le
- NLAlib.Ops.Examples.drawBin
- NLAlib.Ops.Examples.drawBin_apply
- NLAlib.Ops.Examples.drawBin_apply_of
- NLAlib.Ops.Examples.exists_isSrLo
- NLAlib.Ops.Examples.exists_isSrLo_isTapeLaw
- NLAlib.Ops.Examples.integral_dec_srsumF
- NLAlib.Ops.Examples.isSrAdd_link
- NLAlib.Ops.Examples.measurable_srsumF
- NLAlib.Ops.Examples.runsLaw_srsum
- NLAlib.Ops.Examples.runsLaw_srsum_link
- NLAlib.Ops.Examples.runs_srsum
- NLAlib.Ops.Examples.srAddImpl
- NLAlib.Ops.Examples.srAdd_satisfies
- NLAlib.Ops.Examples.srModel_srWit
- NLAlib.Ops.Examples.srProfile
- NLAlib.Ops.Examples.srTable
- NLAlib.Ops.Examples.srWindow
- NLAlib.Ops.Examples.srWit
- NLAlib.Ops.Examples.sr_certifies
- NLAlib.Ops.Examples.srsum
- NLAlib.Ops.Examples.srsumF