Skip to content

Commit

Permalink
Merge pull request #54 from zhengjxu/patch-1
Browse files Browse the repository at this point in the history
Fix bug in oneRandomWalk
  • Loading branch information
wzhe06 authored Sep 9, 2021
2 parents 90d20f8 + 86bc669 commit 579577c
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ object Embedding {

val probDistribution = transitionMatrix(curElement)
val randomDouble = Random.nextDouble()
var accumulateProb: Double = 0D
breakable { for ((item, prob) <- probDistribution) {
if (randomDouble >= prob){
accumulateProb += prob
if (accumulateProb >= randomDouble){
curElement = item
break
}
Expand Down

0 comments on commit 579577c

Please sign in to comment.