# [Ifeffit] Use of restraint

Bruce Ravel bravel at bnl.gov
Wed Jun 22 10:55:50 CDT 2016

```Maureen,

A restraint is implemented in Larch and Ifeffit as a term that is
can be of any functional form.  Matt's example in the talk that you
provided the link for involves a well-shaped functional form using
ifeffit's built-in "penalty" function.  That function is has linear
walls with a flat bottom.

The idea of that functional form is that you think you know the
approximate value of parameter.  For instance, you might think that S02
should be between 0.7 and 0.95.  As long as the fitted value of S02 is
between 0.7 and 0.95, the penalty will evaluate to 0 and there will be
no addition to chi-square.  As the fitted value of S02 wanders outside
of that range, the restraint takes on a value which is added in

within range, but allows it to go outside of the range if the data part
of the fit improves enough to overcome the penalty imposed by the
restraint part of the fit.  So S02 can be a bit outside of the range if
it really, truly improves things.  To say that another way, the
restraint is a way to allow the fit to prove your initial assumption
wrong (or accept it if it is right).

The restraint is not required to have this functional form.  The
well-shaped function is handy, but it can be anything.  Here's an
example:
http://bruceravel.github.io/demeter/documents/Artemis/extended/bvs.html#using-a-bond-valance-sum-as-a-restraint
(That's mostly taken from a similar example Matt presented in a talk
on bond valence sums -- a bit of googling should turn up that talk of his.)

In Artemis, you specify the restraint with a math repression.  In that
sense, it is just like a def parameter.  However, the restraint is
handled differently behind the scenes.  Ifeffit and Larch each have
their way of specifying a restraint -- Artemis does the right thing with
the restraint's math expression.

At the end of the fit, Artemis simply evaluates the math expression.
That evaluation is the thing that is added in quadrature to the data
part of chi-square.  The chi-square reported in the log file is the
sum-in-quadrature of the data part and the restraint part.

All of that makes all kinds of sense, but only because I haven't
discussed how much you should trust you assumptions.  That is, in the
S02 example above, you need to decide how strongly you believe that S02
should be between 0.7 and 0.95.  If you are highly confident, then the
scaling factor should be large.  That will make the evaluation of the
restraint a large number even for a small deviation from the bounds.
When added in quadrature to the data part of chi-square, this will have
the effect of only allowing S02 to wander out of bounds if is REALLY,
REALLY improves the fit.

If, on the other hand, you aren't feeling very confident of your
assumption about S02, make the scale a small number.  This will have the
effect of allowing a much bigger deviation from the bounds before the
penalty applied to chi-square has an impact.

The thing about "square root of chi-square" is an observation that's
been made over the years.  That's a size that tends to be neither large
nor small in the sense explained above.  It's a size that doesn't show
high confidence in the assumption, but does show some confidence.  How
much confidence you have is something you have to decide for yourself.

Hope that helps,
B

On 06/22/2016 09:05 AM, Maureen Le Bars wrote:
> Hello,
>
> I have a couple of questions about data analysis on artemis
>
> I used a restraint for my fits. I've read some documentation about it
> and found Matt Newville's talk
> (https://pubweb.bnl.gov/~frenkel/BNLworkshop2001/newville.pdf). It is
> reported that a restraint adds a "V" term to the chi-square (slides
> number 16 and 17).
>
> According to this formula, what is the number that artemis gives for the
> "restrain" parameter at the end of the fit? How should we consider this
> number in the evaluation of the fit ?
>
> I also don't really know very much about the scaling factor to apply in
> the formula : scale*penalty(X,a,b). I've read that the square root of
> chi-squareseems to be a good size from some of Bruce Ravel's answers in
> ifeffit mailing list. How does the scaling factor control the restraint
> ? What is its relationship with the chi-square ?
>
>
> Maureen
>
> //CEREGE - Europôle de l'Arbois//
> //BP 80//
> //13545 Aix en Provence Cedex 4
> France
> +33 4 42 97 15 48/
>
>
>
> _______________________________________________
> Ifeffit mailing list
> Ifeffit at millenia.cars.aps.anl.gov
> http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit
> Unsubscribe: http://millenia.cars.aps.anl.gov/mailman/options/ifeffit
>

--
Bruce Ravel  ------------------------------------ bravel at bnl.gov

National Institute of Standards and Technology
Synchrotron Science Group at NSLS-II
Building 743, Room 114
Upton NY, 11973

Homepage:    http://bruceravel.github.io/home/
Software:    https://github.com/bruceravel
Demeter:     http://bruceravel.github.io/demeter/
```