Commit 0e2fc169 by AVANZINI Martin

parent a50ffcd4
 # variation of random walk def bridge(): var a, b, n while a < x and x < b: tick 1 prob(1,1): x = x - 1 else: x = x + 1 var a, b, x while a < x and x < b: tick 1 prob(1,1): x = x - 1 else: x = x + 1
 # Coupon Collector's Problem # Upper Bound: O(n*ln n) def collector(): var coupons, draw coupons = 0 draw = 0 while 0 <= coupons and coupons < 10: tick 1 draw = unif(0,10) if draw > coupons: coupons = coupons + 1
 # Coupon Collector's Problem # Upper Bound: O(n*ln n) def collector(): var coupons, draw coupons = 0 draw = 0 while 0 <= coupons and coupons < 100: tick 1 draw = unif(0,100) if draw > coupons: coupons = coupons + 1
 # Coupon Collector's Problem # Upper Bound: O(n*ln n) def collector(): var coupons, draw coupons = 0 draw = 0 while 0 <= coupons and coupons < 50: tick 1 draw = unif(0,50) if draw > coupons: coupons = coupons + 1
 # Coupon Collector's Problem # Upper Bound: O(n*ln n) def collector(): var coupons, draw, N coupons = 0 while 0 <= coupons and coupons < N: tick 1 # draw = unif(0,N-1) draw = rand(N) draw = draw + 1 if draw > coupons: coupons = coupons + 1
 # Coupon Collector's Problem # Upper Bound: O(n*ln n) def collector(): var coupons, draw, N coupons = 0 while 0 <= coupons and coupons < N: tick 1 # draw = unif(0,N-1) draw = rand(N) draw = draw + 1 if draw > coupons: coupons = coupons + 1
 # Variation of linear/trader.imp def trader(): var price, min, nShares, tick_z while price > min and min >= 0: prob (1,3): price = price + 1 else: price = price - 1 nShares = unif(0,10) while nShares > 0: nShares = nShares - 1 tick_z = tick_z + price
 # Variation of linear/trader.imp def trader(): var price, min, nShares, tick_z while price > min and min >= 0: prob (1,3): price = price + 1 else: price = price - 1 nShares = unif(0,100) while nShares > 0: nShares = nShares - 1 tick_z = tick_z + price
 # Variation of linear/trader.imp def trader(): var price, min, nShares, tick_z while price > min and min >= 0: prob (1,3): price = price + 1 else: price = price - 1 nShares = unif(0,500) while nShares > 0: nShares = nShares - 1 tick_z = tick_z + price
 # Variation of linear/trader.imp def trader(): var price, min, nShares, tick_z while price > min and min >= 0: prob (1,3): price = price + 1 else: price = price - 1 nShares = unif(0,50) while nShares > 0: nShares = nShares - 1 tick_z = tick_z + price
 ... ... @@ -8,7 +8,7 @@ def trader(): else: price = price - 1 nShares = unif(0,10000) nShares = unif(0,50) while nShares > 0: nShares = nShares - 1 ... ...
 # Variation of linear/trader.imp def trader(): var price, min, nShares, tick_z while price > min and min >= 0: prob (1,3): price = price + 1 else: price = price - 1 nShares = unif(0,500) while nShares > 0: nShares = nShares - 1 tick_z = tick_z + price
 ... ... @@ -8,7 +8,7 @@ def trader(): else: price = price - 1 nShares = unif(0,100000) nShares = unif(0,500) while nShares > 0: nShares = nShares - 1 ... ...
 # Variation of linear/trader.imp def trader(): var price, min, nShares, maxShares while price > min and min >= 0: prob (1,3): price = price + 1 else: price = price - 1 nShares = rand(maxShares) while nShares > 0: nShares = nShares - 1 tick price
 ... ... @@ -14,8 +14,8 @@ extra-source-files: Flag Debug Description: Enable debug support Manual: False Default: False Manual: True Default: True library hs-source-dirs: src ... ...
 ... ... @@ -231,15 +231,15 @@ norms c = S.fromList [n | GNorm _ _ n <- gNorms c] -- pretty printers instance PP.Pretty Norm where pretty (Norm _ e) = PP.underline (PP.pretty e) pretty (Norm _ e) = PP.text "<" PP.<> PP.pretty e PP.<> PP.text ">" -- pretty (Norm g e) = PP.brackets (PP.hang 0 (PP.pretty e PP. PP.text "|" PP.<+> PP.pretty g)) instance (PP.Pretty c, Eq c, Num c) => PP.Pretty (CExp c) where pretty = pp id where pp _ (N 0 _) = PP.text "0" pp par (N 1 n) = par (ppNorm n) pp _ (N 1 n) = PP.pretty n pp _ (N k (Norm _ 1)) = PP.pretty k pp _ (N k n) = PP.pretty k PP.<> PP.text "·" PP.<> PP.parens (ppNorm n) pp _ (N k n) = PP.pretty k PP.<> PP.text "·" PP.<> PP.pretty n pp par (Div c e) = par (infx (pp id c) "/" (PP.pretty e)) pp par (Plus c d) = par (infx (pp id c) "+" (pp id d)) pp _ (Sup c d) = ppFun "sup" [ PP.pretty c, PP.pretty d ] ... ... @@ -248,7 +248,6 @@ instance (PP.Pretty c, Eq c, Num c) => PP.Pretty (CExp c) where | otherwise = PP.text "ite" PP.<> PP.tupled [ PP.pretty g, pp id c, pp id d ] ppFun f ls = PP.text f PP.<> PP.tupled ls infx l s r = PP.hang 1 (l PP. PP.text s PP.<+> r) ppNorm (Norm _ e) = PP.pretty e instance (PP.Pretty c, Eq c, Ord c, Num c) => PP.Pretty (GNorm c) where ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!