- sampling
- support
(i.e. a set of values where all elements outside the set have zero chance of being sampled) - expectation of a function over the distribution
(e.g. the probability of selecting elementA
by evaluating the functionf(x) = 1
ifx
equalsA
and0
otherwise)
Contrast the F# implementation with the Scala implementation. The Scala implementation closely follows the F# one, except for one major frustration: the type inference is not as powerful in Scala, as all function arguments must be declared.
Perhaps, I am missing a few tricks because I am new to Scala. If anyone has any suggestions for improving the Scala implementation, please share.
Cross-posted to the Scala wiki.
1 comment:
Scala doesn't infer argument types. As for return types, you've run into an oddity in Scala's type system.
scala> sealed abstract class Foo
scala> case object Bar extends Foo
scala> case object Baz extends Foo
scala> val z = List(Bar,Baz)
z: List[Product with Foo] = List(Bar, Baz)
Bar and Baz are in fact products...but do I care? Not really. And that seems to be a big chunk of why you have to specify so many return types - to throw away the Product bit.
Post a Comment