Last active
September 30, 2026 05:45
-
-
Save coderodde/7300fcafd69f3ce1f97c2a86600c03ac to your computer and use it in GitHub Desktop.
TimeDependentBayes.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package io.github.coderodde.math.prob.timebayes; | |
| public final class TimeDependentBayesJava { | |
| public static interface IntervalEvent { | |
| public abstract double probability(double t); | |
| } | |
| public static final IntervalEvent EVENT_B = | |
| (double t) -> t; | |
| public static final IntervalEvent INTERSECTION_EVENT = | |
| (double t) -> Math.max(0.0, 2 * (t - 0.5)); | |
| public static double probability(double t) { | |
| return INTERSECTION_EVENT.probability(t) / EVENT_B.probability(t); | |
| } | |
| public static void main(String[] args) { | |
| System.out.println("t P"); | |
| double dt = 1.0 / 20; | |
| double t = dt; | |
| for (int i = 0; i < 20; ++i) { | |
| System.out.println("%f %f".formatted(t, probability(t))); | |
| t += dt; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment