Skip to content

feat: Update calculation of predictions #159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mhovd
Copy link
Collaborator

@mhovd mhovd commented Jul 17, 2025

Population and individual predictions are now calculated using the (weighted) mean/median response, instead of the (weighted) mean/median support.

@Copilot Copilot AI review requested due to automatic review settings July 17, 2025 17:34
@mhovd mhovd linked an issue Jul 17, 2025 that may be closed by this pull request
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR changes the calculation method for population and individual predictions from using the weighted mean/median support points to using the weighted mean/median of the actual response values. This represents a fundamental shift in how predictions are computed, moving from parameter-space averaging to response-space averaging.

Key changes:

  • Modified prediction calculation to compute weighted mean/median of simulated responses instead of simulating from weighted mean/median parameters
  • Updated weighted_median function signature to use Vec<f64> instead of Array1<f64> for consistency
  • Added comprehensive simulation across all support points for each subject before aggregating results
Comments suppressed due to low confidence (4)

src/routines/output.rs:430

  • The variable name spp is ambiguous. Consider renaming it to support_point or theta_row to make its purpose clearer.
            for spp in theta.row_iter() {

src/routines/output.rs:432

  • The variable name spp_values is ambiguous. Consider renaming it to support_point_values or theta_values to make its purpose clearer.
                let spp_values = spp.iter().cloned().collect::<Vec<f64>>();

src/routines/output.rs:446

  • The variable name outer_pred is unclear. Consider renaming it to support_point_predictions or spp_predictions to better indicate it represents predictions from a specific support point.
            for outer_pred in predictions.iter().enumerate() {

src/routines/output.rs:448

  • The variable name inner_pred is unclear. Consider renaming it to time_point_prediction or prediction_at_time to better indicate it represents a prediction at a specific time point.
                for inner_pred in outer_pred.iter().enumerate() {

@@ -764,7 +785,7 @@ pub fn median(data: Vec<f64>) -> f64 {
}
}

fn weighted_median(data: &Array1<f64>, weights: &Array1<f64>) -> f64 {
fn weighted_median(data: &Vec<f64>, weights: &Vec<f64>) -> f64 {
Copy link
Preview

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function parameters should use slice references (&[f64]) instead of &Vec<f64> for better API design and flexibility. This allows the function to accept both vectors and slices.

Suggested change
fn weighted_median(data: &Vec<f64>, weights: &Vec<f64>) -> f64 {
fn weighted_median(data: &[f64], weights: &[f64]) -> f64 {

Copilot uses AI. Check for mistakes.

Copy link
Contributor

github-actions bot commented Jul 17, 2025

🐰 Bencher Report

Branch157-change-how-meanmedian-population-predictions-are-calculated
Testbedorion
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
seconds (s)
(Result Δ%)
Upper Boundary
seconds (s)
(Limit %)
bimodal_ke_fit📈 view plot
🚷 view threshold
10.13 s
(-32.34%)Baseline: 14.97 s
26.46 s
(38.29%)
🐰 View full continuous benchmarking report in Bencher

@LAPKB LAPKB deleted a comment from Copilot AI Jul 17, 2025
@mhovd
Copy link
Collaborator Author

mhovd commented Jul 17, 2025

Before this can be merged, we need to handle the occasion correctly.

output.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change how mean/median population predictions are calculated
1 participant