diff --git a/src/compute_constrained_bayes.nim b/src/compute_constrained_bayes.nim index 4b8d353..cc1f36d 100644 --- a/src/compute_constrained_bayes.nim +++ b/src/compute_constrained_bayes.nim @@ -192,11 +192,53 @@ proc miniInfraBayes( echo "And hence a loss of ", new_loss echo "Total loss is: ", foldl(losses, a + b, 0.0) +proc getEvens(xs: seq[string]): seq[string] = + var evens: seq[string] + for i,x in xs: + if i%2 == 0: + evens.add(x) + return evens -## Infrabayesianism. Part 1: Have hypotheses over just part of the world. +proc getOdds(xs: seq[string]): seq[string] = + var odds: seq[string] + for i,x in xs: + if i%2 == 1: + odds.add(x) + return odds +proc miniInfraBayes2( + seqs: seq[seq[string]], + observations: seq[string], + n_observations_seen: int, + utility_function: string + ) = + if utility_function != "logloss": + echo "miniInfraBayes function only programmed for the logloss utility function" + return + else: + echo "## Mini-infra-bayesianism over environments, where your utility in an environment is just the log-loss in the predictions you make until you become certain that you are in that environment. This time with a twist: You don't have hypotheses over the sequences you observe, but rather over their odd and even position, i.e., you think that you observe interleaved OEIS sequences, (a1, b1, a2, b2, a3, b3). See the README.md for more." -## Infrabayesianism. Part 2: Take the infimum over the possible loss. + var losses: seq[float]g + for i in n_observations_seen.. getHypothesis(prediction)) + let correct_continuation_index = findIndex(considered_continuations, correct_continuation) + let p_correct_continuation = getProbability(predictions[correct_continuation_index]) + let new_loss = ln(p_correct_continuation) + losses.add(new_loss) + + echo "Correct continuation was ", correct_continuation + echo "It was assigned a probability of ", p_correct_continuation + echo "And hence a loss of ", new_loss + echo "Total loss is: ", foldl(losses, a + b, 0.0) ## Display outputs echo ""