Commit c11ed974 by AVANZINI Martin

### uniform-dist optimisation also in constant case

parent 54831dae
 ... ... @@ -211,17 +211,18 @@ boundedSum f (l,o) = expectation :: E.Dist E.Exp -> (E.Exp -> CostExpression) -> SolveM CostExpression expectation (E.Discrete ls) f = discreteExpectation ls (return . f) expectation (E.Rand (E.Constant n)) f = discreteExpectation [(1,E.constant i) | i <- [0..n-1]] (return . f) -- expectation (E.Rand (E.Constant n)) f = -- discreteExpectation [(1,E.constant i) | i <- [0..n-1]] (return . f) expectation (E.Rand n) f = logBlkIdM ("[expectation] " ++ "rand(" ++ show (PP.pretty n) ++ ")") \$ do let (vi,vj) = (E.Named "@i", E.Named "@j") (fi,fj) = (f (E.variable vi), f (E.variable vj)) logMsg2 "f" fi C.guarded (n .> 0) <\$> case linFn fi vi (C.scale (1 / 2) (C.fromExp n)) of case n of _ | fi == fj -> return fi Just g -> return g | Just g <- linFn fi vi (C.scale (1 / 2) (C.fromExp n)) -> return g E.Constant n' -> discreteExpectation [(1,E.constant i) | i <- [0..n'-1]] (return . f) _ | otherwise -> C.divBy <\$> boundedSum f (0,n-1) <*> pure n where noccur v (C.Norm e) = v `notElem` E.variables e ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!