diprism / fggs

Factor Graph Grammars in Python
MIT License
13 stars 3 forks source link

Expected value NaN #151

Closed davidweichiang closed 2 years ago

davidweichiang commented 2 years ago

From @ccshan:

data Flip = H | T;
data Flips = Cons Flip Flips;
data Unit = unit;
extern tick: Unit; 
define flips = Cons (sample uniform) flips;
define search = \fs: Flips. let _ = tick in
 case fs  of | Cons f1 fs1 -> if f1 == T then search fs1 else
 case fs1 of | Cons f2 fs2 -> if f2 == H then search (Cons H fs2) else
 case fs2 of | Cons f3 fs3 -> if f3 == T then search (Cons T (Cons T fs3)) else let _ = tick in tick;
search flips

Output:

E[#tick]: [NaN]
ccshan commented 2 years ago

(This is the same program as diprism/compiler#60 but with tick counting using the -e flag on the grad branch)