4.8. Relative Score Method — General

imselection.compute_rsm_general(demands, im1_values, im2_values, pdf_func_im1, pdf_func_im2)[source]

General Relative Sufficiency Measure using user-supplied PDF callables.

Implements Equation 1 of Ebrahimian & Jalayer (2021). Useful for custom demand models or non-lognormal formulations.

Parameters:
  • demands (array_like) – EDP value for each record, shape (N,).

  • im1_values (array_like) – IM₁ value for each record, shape (N,).

  • im2_values (array_like) – IM₂ value for each record, shape (N,).

  • pdf_func_im1 (callable) – f(d_k, im1_k) float — probability density of demand d_k given IM₁ = im1_k.

  • pdf_func_im2 (callable) – f(d_k, im2_k) float — same for IM₂.

Returns:

  • dict with keys

  • * 'rsm' — scalar RSM in bits

  • * 'rsm_per_record' — ndarray of per-record log₂ ratios

  • * 'n_records' — total records

  • * 'n_valid' — records with finite log₂ ratio

  • * 'method''general'

Example

from openquake.vmtk.imselection import imselection

ims = imselection()
# edps, im1_values, im2_values: 1-D arrays of equal length
result = ims.compute_rsm_general(edps, im1_values, im2_values)
print(f"RSM = {result['rsm']:.4f} bits")