Skip to content

Commit

Permalink
Normalize Selects during factor creation. Address issue #715
Browse files Browse the repository at this point in the history
  • Loading branch information
bruttenberg committed Oct 18, 2017
1 parent 7139003 commit cf89bba
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ object SelectFactory {
*/
def makeSimpleDistribution[T](target: Variable[T], probs: List[Double]): Factor[Double] = {
val factor = new DenseFactor[Double](List(), List(target))
for { (prob, index) <- probs.zipWithIndex } {
val sum = probs.sum
for { (prob, index) <- probs.map(_/sum).zipWithIndex } {
factor.set(List(index), prob)
}
factor
Expand Down

0 comments on commit cf89bba

Please sign in to comment.