packages feed

lazyppl-singlesite-0.2.0: test/GuidedReference.hs

-- | Independent ideal four-state reference, consumed by CompletedHooks.
--
-- States are 00, 01, 10, 11. Target weights are 1, 2, 3, 4. The probability
-- of choosing the first site is respectively 1/4, 3/4, 1/2, 3/4. A selected
-- coordinate is redrawn as a fair Boolean. A fixed 1/8 component redraws both.
--
-- For example, 00 -> 01 has local q=3/8, reverse q=1/8 and acceptance 2/3,
-- hence P=1/4. Its stationary flow is 1/40 in both directions. Reusing the
-- current guide in the reverse ratio instead gives mixed flows 23/640 and
-- 9/640, a defect of 7/320. Moving on rejection gives local flows 3/80 and
-- 1/40, a defect of 1/80. These literals were specified independently of the
-- kernel; they are not calculated by its acceptance or transition functions.
module GuidedReference (qLocal, aLocal, pLocal, pMissing, pChanging, pRefresh, pMixed) where

import Data.Ratio ((%))

qLocal, aLocal, pLocal, pMissing, pChanging, pRefresh, pMixed :: [[Rational]]
qLocal =
  [[1%2,3%8,1%8,0], [1%8,1%2,0,3%8],
   [1%4,0,1%2,1%4], [0,3%8,1%8,1%2]]
aLocal =
  [[1,2%3,1,0], [1,1,0,1],
   [1%6,0,1,2%3], [0,1%2,1,1]]
pLocal =
  [[5%8,1%4,1%8,0], [1%8,1%2,0,3%8],
   [1%24,0,19%24,1%6], [0,3%16,1%8,11%16]]
pMissing =
  [[3%4,1%4,0,0], [1%8,1%2,0,3%8],
   [0,0,5%6,1%6], [0,3%16,1%8,11%16]]
-- Inactive hidden false, inactive hidden true, active true, active false.
-- An inactive state activates with probability 1/2 and reveals its retained
-- bit. Active-to-inactive proposals have mass 1/4; their acceptances are 1
-- and 1/2 for weights 2 and 4. Switching the active bit has proposal mass
-- 1/4 and acceptances 1 and 1/2. The remaining mass stays in each state.
pChanging =
  [[1%2,0,0,1%2], [0,1%2,1%2,0],
   [0,1%4,1%2,1%4], [1%8,0,1%8,3%4]]
pRefresh =
  [[1%4,1%4,1%4,1%4], [1%8,3%8,1%4,1%4],
   [1%12,1%6,1%2,1%4], [1%16,1%8,3%16,5%8]]
pMixed =
  [[37%64,1%4,9%64,1%32], [1%8,31%64,1%32,23%64],
   [3%64,1%48,145%192,17%96], [1%128,23%128,17%128,87%128]]