On 02/28/2014 07:52 AM, Cristina Alonso Escobar wrote:
1.- How can I restrain "a" ? I tried to manually add a restraint, but I do not know how to make an interval restraint...( 0
2.- If you select "restrain" and after in the math expression "build restrain from ..." What is the meaning of scale by? Why the program duplicate the restrain (i.e restrain- a and restrain- res_a - 1* penalty (a, 0, 1)? I think I am not doing well because the value of my parameter "a" is suspiciously always 0.
In Artemis and in Ifeffit, a "constraint" is a mathematical relation between parameters. A "restraint" is a math expression which is evaluated and added in quadrature to chi-square when the fit is evaluated. The "penalty" function has this functional form: penalty(a, min, max) = 0 for min < a < max penalty(a, min, max) = a-max for a > max penalty(a, min, max) = min-1 for a < min This is useful as a restraint because it assesses no penalty in the evaluation of chi-square when a is "well-behaved", i.e. between min and max. As a deviates from its range, the penalty increases linearly by its excursion out of range. This will serve the purpose of a restraint. Since it is added in quadrature to chi-square, it has no impact on chi-square as long as a stays within range. It can, however, leave its range so long as there is a compensating improvement in the quality of the fit. The "scale" term is needed because you want the restraint to be significant on the scale of chi-square. If the restraint is too small, then the fit will not be sensitive to it and a will not be encouraged to stay within its range. If the restraint is too big, then a will not be allowed out of range even if that would improve the quality of fit. As a rule of thumb, I find that the square root of chi-square in the absence of the restraint is about the right size for the scaling factor. So if, chi-square without the restraint is 400, set scale = 20 restrain my_res = scale * penalty(a, 0 , 1) A few additional points: 1. The restraint I described above is linear in its excursion out of bounds. You can make it quadratic very simply: set scale = 20 restrain my_res = scale * (penalty(a, 0 , 1))**2 2. You don't have to use the penalty function. Any expression can be a restraint and get added in quadrature to chi-square. Here's a talk Matt gave many years ago in which he explains restraints very clearly. At the end he also gives an example of restraint that does not use the penalty function. https://pubweb.bnl.gov/~frenkel/BNLworkshop2001/newville.pdf 3. There is another way in Artemis (and Ifeffit) to set a boundary on a parameter value: guess b = 0.5 def a = max(0, min(1, b)) This sets hard-wall boundaries on a. This is not as attractive as you might think, however. Because the boundaries are hard walls, if the fit is pushing the value beyond one of the walls, error bars can no longer be computed. This is because values outside the hard-wall boundaries do not change the fit, thus the covarience matrix cannot be calculated, and error bars cannot be determined. Restraints are an improvement on hard wall boundaries in that they allow error bars to be evaluated. You can make a restraint behave somewhat like a hard wall by making the scaling factor large. 4. You said "I think I am not doing well because the value of my parameter 'a' is suspiciously always 0." I find that that sort of thing is usually trying to tell me something about my fit. In your case, I would encourage you to think about how a is used in the fit. You think that a should be bigger than 0, but perhaps the fit is trying to tell you either that your assumption is mistaken or that your fitting model has a mistake. Just something to think about .... 5. There is hope for better things on the horizon. Larch has a much more robust way of restraining parameter values than does Ifeffit. http://xraypy.github.io/xraylarch/fitting/parameters.html#setting-bounds Artemis is not ready to begin using Larch, but it will one of these days. Then you will have access to much richer tools for defining fitting parameters. Something to look forward to.... HTH, B -- Bruce Ravel ------------------------------------ bravel@bnl.gov National Institute of Standards and Technology Synchrotron Science Group at NSLS --- Beamlines U7A, X24A, X23A2 Building 535A Upton NY, 11973 Homepage: http://xafs.org/BruceRavel Software: https://github.com/bruceravel