danielkorzekwa / bayes-scala

Bayesian Networks in Scala
Other
205 stars 39 forks source link

A more scala-esque interface to the classes #3

Closed erikkaplun closed 10 years ago

erikkaplun commented 10 years ago

I'm browsing through the examples and wondering why the data structures are built in an imperative manner as opposed to declarative? Is there a particular reason for this to be the case?

danielkorzekwa commented 10 years ago

It was simply quicker to address particular inference needs I had. If I had more time, I would likely built more declarative api to hide the details of clusters, factors and inference algorithms.

erikkaplun commented 10 years ago

By the way, is there a particular reason to have a mutable API to start with? i.e. why not build the entire library to be as immutable as possible right from the start? (this is of course a hypothetical question anyway)

danielkorzekwa commented 10 years ago

With the current api design (imperative and algorithm abstraction level) some elements were more natural to be created as state full objects, e.g. factor graphs. Other objects, such as factors and variables are indeed immutable. With a different api style like:

val meanPrior = Gaussian(mean,variance1)
val observation = Gaussian(meanPrior,variance2).observed(value)
val meanPosterior = eval(meanPrior)

it is more natural to create a functional api, as you do not operate directly on factors and factor graphs.