# Re: simultaneous fitting

From: John Houck <houck_at_email.domain.hidden>
Date: Mon, 2 Feb 2009 12:57:58 -0500
```On Mon, Feb 02, 2009 at 12:17 -0500, Herbert Pablo wrote:
> Hey all,
>
> I have been mulling this over for quite a while and I can't
> seem to come up with an adequate answer. What I'm trying to do
> is fit both the plus and minus orders of a grating together.
> Now if I want to fit them simultaneously. I just load both in
> and use xnotice to tell which datasets and what wavelengths I
> want to fit. That seem relatively straightforward. What I want
> to know is the fundamental difference between fitting in this
> manner, and first combining the two and then trying to fit.

The statistic to be minimized during the fit depends on an
array of data values, D, and a corresponding array of model
values, M.

Given two datasets, two data arrays are available -- call them
d1 and d2.  Two corresponding model arrays can be computed --
call them m1 and m2.

When the datasets are fitted "simultaneously", the
fit-statistic is computed using the concatenated data arrays
and concatenated model arrays:

D = {d1, d2}
M = {m1, m2}

When "combined" datasets are fitted, the statistic is computed
using the summed data and summed model.  In the simplest case:

D = d1 + d2
M = m1 + m2

To simplify computation of these sums, isis assumes that d1 and
d2 are on the same grid and that the same wavelength ranges are
noticed in both datasets.  Also, the sum is computed
"on-the-fly" and is not saved internally.

The main advantage of "combining" is that each data bin has
better statistics.

> I understand essentially what it means to combine datasets, but
> when I try to fit them, I'm not sure what I should put in. For
> example
>
> g=combine_datasets(heg+1,heg-1);
> hegcomb=get_combined(g,&get_data_flux);
>
> now if I say xnotice(hegcomb, 1.7, 2.3);
>
> xnotice doesn't understand this structure type.

Right.  It doesn't understand the group id 'g' either.

Perhaps this does what you want:
xnotice (combination_members(g), 1.7, 2.3)

> If I tell it:
>
> xnotice(1, 1.7,2.3);
>
> It says ranges for 1 and 2 do not match.

I assume this error appears when you try to fit?
This happens because you're trying to combine datasets
with different bin ranges noticed.

> If I put in
>
> xnotice(1, 1.7,2.3);
> xnotice(2, 1.7,2.3);
>
> It doesn't balk, but the fit is pretty lousy versus just
> looking at one spectra at a time. Plus, the fact that it needs
> ranges for both the + and - order leads me to believe that it
> isn't fitting the combined spectra at all.

Are the data in counts or flux units?

When combining flux spectra, you may wish to provide weights so
that the combined spectrum reflects the average flux rather
than the sum.  Weights may be provided by an optional second
parameter to combine_datasets.

> Any light you can shed on this would be greatly appreciated.
>
> Thanks,
> Bert
>

Thanks,
-John
----
You received this message because you are
subscribed to the isis-users list.
To unsubscribe, send a message to
isis-users-request_at_email.domain.hiddenwith the first line of the message as:
unsubscribe
```
Received on Mon Feb 02 2009 - 12:58:20 EST

This archive was generated by hypermail 2.2.0 : Tue Nov 13 2012 - 08:45:42 EST