Marginalisation of a parameter

Hi everyone, I have a problem with the marginalisation concept.
I have a matrix (NxM), where:
  1. N refers to the models I tested;
  2. M refers to the parameters of each model (i.e., all models have the same M parameters (mass, age, etc., they refer to galaxy properties).
Because I have N models I tested, I also have N chi2 values. I want to marginalise one parameter over the M-1 other parameters. Someone told me that I have to convert each chi2 values in probability with ~exp(-chi2/2) and sum all the values weighted with this probability, projected on the parameter of interest. However, I do not know how to proceed.
Can anyone help me with this problem?