Skip to content

Commit 2edaff7

Browse files
committed
Fix ground process intensity calculation in GMM model
Replaces use of log-probabilities with exponentiated densities for ground process intensity calculation and applies clipping to avoid numerical issues. Also updates the use of mean_rate to mean_rates[-1] and ensures safe division only when occupancy is above a threshold.
1 parent f75fd20 commit 2edaff7

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/non_local_detector/likelihoods/clusterless_gmm.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,15 @@ def fit_clusterless_gmm_encoding_model(
374374
joint_models.append(joint_gmm)
375375

376376
# Expected-counts term at bins: mean_rate * (gpi / occupancy)
377-
gp_num = _gmm_logp(gpi_gmm, interior_place_bin_centers) # (n_bins,)
378-
summed_ground_process_intensity += mean_rate * safe_divide(gp_num, occupancy)
379-
380-
summed_ground_process_intensity = jnp.clip(
381-
summed_ground_process_intensity,
382-
min=EPS,
383-
)
377+
gpi_density = jnp.exp(
378+
_gmm_logp(gpi_gmm, interior_place_bin_centers)
379+
) # (n_bins,)
380+
summed_ground_process_intensity += jnp.clip(
381+
mean_rates[-1]
382+
* safe_divide(gpi_density, occupancy, condition=occupancy > EPS),
383+
a_min=EPS,
384+
a_max=None,
385+
)
384386

385387
return {
386388
"environment": environment,

0 commit comments

Comments
 (0)