Bimodal posterior distribution

Hi. I need some help with improving my code. In my study, I’m working on the problem of localizing a radioactive source. The radiation detection device cannot determine which side of the road the radiation originated from, resulting in probable positions for the source on both sides of the road—i.e., a bimodal posterior distribution. To account for this, I implemented a “mirroring” technique for the posterior, which provides suitable results. However, I’m wondering if there might be a smarter way to handle this, perhaps through a custom sampler? Any advice are more than welcome.

with pm.Model() as cps_angl_model:
    alpha = pm.Gamma('alpha', mu=10000, sigma=100)  
    beta = pm.Gamma('beta', mu=100, sigma=10)
    
    x_left = pm.Uniform("x_src_left", lower=LOWER_X, upper=LEFT_X_MIN)
    x_right = pm.Uniform("x_src_right", lower=RIGHT_X_MIN, upper=UPPER_X)
    y_left = pm.Uniform("y_src_left", lower=LEFT_Y_MIN, upper=UPPER_Y)
    y_right = pm.Uniform("y_src_right", lower=LOWER_Y, upper=RIGHT_Y_MIN)
    
    angles_left = tensor_calc_angles(pos_x_tt, pos_y_tt, x_left , y_left)
    angles_right = tensor_calc_angles(pos_x_tt, pos_y_tt, x_right, y_right)

    eff_rel_left = f_inter_tt(angles_left)
    eff_rel_right = f_inter_tt(angles_right)
    
    act = pm.Gamma("act", alpha=alpha, beta=beta, initval=1000)
    bkg = pm.Normal("bkg", mu=MEAN_BKG_CPS, sigma=BKG_STD, initval=MEAN_BKG_CPS)

    count_rate = mean_angular_cps_tt(pos_x_tt, pos_y_tt, x_left, y_left, act, bkg, eff_rel_left)
    count_rate1 = mean_angular_cps_tt(pos_x_tt, pos_y_tt, x_right, y_right, act, bkg, eff_rel_right)
    cps_obs = pm.Poisson("cps_obs", mu=count_rate, observed=cps)
    cps_obs1 = pm.Poisson("cps_obs_mir", mu=count_rate1, observed=cps)

Is there a particular reason why you need distributions on either side of the road? Could you re-parameterize the problem so that you have a parametric position on the road (say going from 0 to 1) and then post-process the data (or use pymc.Deterministic variables) to get the two possible locations?

i.e.

with pm.Model( ) as cps_model:
    alpha = pm.Gamma('alpha', mu=10000, sigma=100)
    beta = pm.Gamma('beta', mu=100, sigma=10)

    act = pm.Gamma("act", alpha=alpha, beta=beta, initval=1000)
    bkg = pm.Normal("bkg", mu=MEAN_BKG_CPS, sigma=BKG_STD, initval=MEAN_BKG_CPS)

    p = pm.Uniform("s", lower=0, upper=1)

    count_rate = get_expected_count( p, act, bkg )

    positions = pm.Deterministic("angle1", tensor_calc_positions(p) )

    likelihood = pm.Poisson( "likelihood", mu=count_rate, observed=cps )

where get_expected_count takes in the parametric position, the source properties, and the background (I assume from your variable names) and gives an expected count rate, tensor_calc_positions takes in the parametric position p and returns the possible source locations, and likelihood compares the modeled count rate to the observed?

Like I mentioned, you could even do the position calculation as a post-processing step on the output trace and then the only implementation is getting the count from the parametric position.

1 Like

Thank you for your response. Essentially, that’s how it works at the moment. Typically, the model should know which side to search from, but sometimes it shows the wrong direction. I was considering enhancing the priors, so to speak, to guide the model toward the correct direction.

How would the model know the side of the road to search on? Is that information in the data or in your understanding of the sensor? My suggestion was to remove the side from the pymc model entirely and just consider position along the road since you have a lot of unnecessary variables in your model from that perspective. If all the sensor can do is sense count and the orientation of the sensor doesn’t matter, I don’t really see how you could better the prediction BUT I may not understand exactly what you’re asking.

Thinking a bit further:

  1. If the sensor had one sensitivity on one side and another on the back, I could see how you could learn something about what side of the the source is on. Especially if you drove down the road in both directions.
  2. If the strength of the counts varied enough when you drove on one side of the road vs. the other just due to that change in distance I could also see how you could also estimate the source placement

In either case, I don’t know enough about how these sensors work to be able to answer that.

Sorry if I’m being obtuse!

It knows the side from the observed data and efficiency of the counter. Sometimes it search on the opposite side of the road which. Perhaps it’s also a problem of data consistency. I like your idea with both directions data. Thanks again