Comparing version 1.1.1 to 1.1.2
@@ -37,2 +37,3 @@ import * as gaussian from 'gaussian'; | ||
next(): MarkovKey; | ||
gaus(links: Map<string | SpecialKey, MarkovAssociation>, curve: MarkovKeyCurve): MarkovKey; | ||
randNext(): MarkovKey; | ||
@@ -39,0 +40,0 @@ gausNext(): MarkovKey; |
@@ -96,11 +96,7 @@ "use strict"; | ||
} | ||
randNext() { | ||
const asses = Array.from(this.links.values()); | ||
return asses[Math.floor(Math.random() * asses.length)].keyRef; | ||
} | ||
gausNext() { | ||
gaus(links, curve) { | ||
let sum = 0; | ||
const pairs = []; | ||
for (const ass of this.links.values()) { | ||
const prob = this.curve.gaussian.cdf(ass.associations); | ||
for (const ass of links.values()) { | ||
const prob = curve.gaussian.cdf(ass.associations) * 100; | ||
pairs.push([ass.keyRef, prob]); | ||
@@ -118,2 +114,9 @@ sum += prob; | ||
} | ||
randNext() { | ||
const asses = Array.from(this.links.values()); | ||
return asses[Math.floor(Math.random() * asses.length)].keyRef; | ||
} | ||
gausNext() { | ||
return this.gaus(this.links, this.curve); | ||
} | ||
prev() { | ||
@@ -133,17 +136,3 @@ const seed = Math.floor(Math.random() * this.parentWeightSum); | ||
gausPrev() { | ||
let sum = 0; | ||
const pairs = []; | ||
for (const ass of this.parents.values()) { | ||
const prob = this.parentCurve.gaussian.cdf(ass.associations); | ||
pairs.push([ass.keyRef, prob]); | ||
sum += prob; | ||
} | ||
const seed = Math.random() * sum; | ||
let accu = 0; | ||
for (const ass of pairs) { | ||
accu += ass[1]; | ||
if (accu >= seed) { | ||
return ass[0]; | ||
} | ||
} | ||
return this.gaus(this.parents, this.parentCurve); | ||
} | ||
@@ -150,0 +139,0 @@ toString() { |
{ | ||
"name": "cat-markov", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "A library to generate markov chains.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70431
1742