Skip to content

Instantly share code, notes, and snippets.

@coderodde
Last active September 30, 2026 05:45
Show Gist options
  • Select an option

  • Save coderodde/7300fcafd69f3ce1f97c2a86600c03ac to your computer and use it in GitHub Desktop.

Select an option

Save coderodde/7300fcafd69f3ce1f97c2a86600c03ac to your computer and use it in GitHub Desktop.
TimeDependentBayes.java
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