=> v (a, Double) -> CondensedTable v a

{-# INLINE tableFromProbabilities #-}

- | G.null v = pkgError "tableFromProbabilities" "empty vector of outcomes"

- | otherwise = tableFromIntWeights $ G.map (second $ round . (* mlt)) v

+ | G.null tbl = pkgError "tableFromProbabilities" "empty vector of outcomes"

+ | otherwise = tableFromIntWeights $ G.map (second $ round . (* mlt)) tbl

- mlt = 4.294967296e9 -- 2^32

+ mlt = 4.294967296e9 -- 2^32

+ tbl = G.filter ((> 0) . snd) v -- Drop non-positive probabilities

-- | Same as 'tableFromProbabilities' but treats number as weights not

-- probilities. Non-positive weights are discarded, and those

-- | Generate a condensed lookup table from integer weights. Weights

-- should sum to @2^32@. If they don't, the algorithm will alter the

-- weights so that they do. This approach should work reasonably well

tableFromIntWeights :: (Vector v (a,Word32), Vector v a, Vector v Word32)