Skip to content

Condition for drawing additional samples - n_eff #37

@NolanSmyth

Description

@NolanSmyth

I'm wondering if there is an error in the conditional check on line 900 of engine.py in the predict function? Currently, the code checks:

if n_max > n_samples and neff > neff_min:

However, I would think the intended logic should be to trigger additional simulations only when the effective sample size is below the minimum threshold. In that case, the condition is:

if n_max > n_samples and neff < neff_min:

In a separate but closely related issue - it would be nice to ensure that there are n_samples returned for the event of no importance sampling. I.e. in line 880:

ys = self._draw_params(x, n_samples)

one could generate more samples in the event that samples outside the prior are removed in line 1245:

params = params[~np.isinf(logprior)].

For example, a hacky way of doing this is to replace line 880 with:

n_total = 0
ys = []
while n_total < n_samples:
    n_needed = n_samples - n_total
    new_ys = self._draw_params(x, int(n_needed*1.1))
    ys.append(new_ys)
    n_total += len(new_ys)

ys = np.concatenate(ys)[:n_samples]

Thanks a lot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions