Warning: session_start(): open(/var/lib/php/sessions/sess_9amnbnjaa87gm23glbpe00qu89, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sclass BodyOfEvidence {
// values are: WithProbability(strengthOfEvidence, probabilityOfTheory)
// will only hold one piece of evidence per src object
Map> examples = syncMap();
double strengthSum, probabilitySum;
O mutex() { ret examples; }
double currentProbabilityGuess() {
synchronized(mutex()) {
ret doubleRatio(probabilitySum, strengthSum);
}
}
S renderProbabilityGuess() {
ret "Current probability guess (evidence count " + n2(l(examples)) + "): " + formatDouble3X(currentProbabilityGuess()) + " with strength " + formatDouble3(strengthSum);
}
bool hasEvidenceFromSource(Src src) { ret examples.containsKey(src); }
bool addEvidence(Src src, double probabilityOfTheory, double strengthOfEvidence) {
synchronized(mutex()) {
if (hasEvidenceFromSource(src)) false;
examples.put(src, withProbability(strengthOfEvidence, probabilityOfTheory));
probabilitySum += probabilityOfTheory*strengthOfEvidence;
strengthSum += strengthOfEvidence;
true;
}
}
S toStringWithEvidence() {
ret toString() + "\n\n"
+ pnlToString("EVIDENCE", examples);
}
}