Skip to content

Latest commit

 

History

History
56 lines (39 loc) · 735 Bytes

IDEA.md

File metadata and controls

56 lines (39 loc) · 735 Bytes
model {
  
  'a = 1.0
  'b = 2.0
   
  foreach(k) {
    'phi ~: Dir('b)
  }
  
  foreach(d in docs)  {
    'theta ~: Dir('a)
  
    foreach(w in words) {
      'z ~: Mult('theta)
      'v ~: Mult('phi('z))
    }
  }

  hints {
    collapse('theta, 'z)
    collapse('w, 'phi)
  }

}


Root {
  Param(Ident("a"))
  Param(Ident("b"))
  Plate(Ident("k"), Range) {
    RV(Ident("phi"), Dir(Ident("b")))
  }
  Plate(Ident("d"), Iterator) {
    RV(Ident("theta"), Dir(Ref("a")))
    Plate(Ident("w"), Iterator) {
      RV(Ident("z"), Mult(Ref("theta")))
      RV(Ident("v"), Mult(Ref("phi", "z")))
    }
  }
}

Usage:

val model = ModelDescription.compile
model.apply(a = 1.0, b = 2.0, k = 10, d = doc.words)