Fwd: problems with setting parameters in new Artemis (Demeter 0.9.16)
Dear All, I am trying to fit the first FT shell in Artemis with a mixture of two different compounds (octahedral and tetrahedral models). I would like to quantify the ratio between this two compounds in my sample so I decided to multiply So2 by a parameter called "a" in one model and by "(1-a)" in the other. I would like to know: 1.- How can I restrain "a" ? I tried to manually add a restraint, but I do not know how to make an interval restraint...( 0http://itq.upv-csic.es Tfno: +34 96 387 7800 Fax: +34 96 387 9444 ----- Terminar mensaje reenviado ----- *** *** *** *** *** *** *** *** *** Cristina Alonso-Escobar. PhD student Instituto de Tecnología Química (UPV-CSIC) Avda. de los Naranjos s/n 46022 Valencia (Spain) http://itq.upv-csic.es Tfno: +34 96 387 7800 Fax: +34 96 387 9444
Hi, The easiest constraint would be a mathematical expression such as "a + b = 1". Do you have an experimental value for so2 as found for something chemically similar such as a standard at that edge? Then replace so2 expression for each path as "value found * a" and "value found * b". This should give a relative percentage for each path contribution. Hope that is clear, Chris ******************************************** Dr. Christopher Patridge Assistant Professor of Chemistry Math and Natural Science Dept BFAC 009 D'Youville College 320 Porter Ave., Buffalo, NY 14150 716-829-8096 Sent from my iPhone
On Feb 28, 2014, at 7:52 AM, Cristina Alonso Escobar
wrote: Dear All,
I am trying to fit the first FT shell in Artemis with a mixture of two different compounds (octahedral and tetrahedral models). I would like to quantify the ratio between this two compounds in my sample so I decided to multiply So2 by a parameter called "a" in one model and by "(1-a)" in the other.
I would like to know:
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.
Thank you in advance,
*** *** *** *** *** *** *** *** ***
Cristina Alonso-Escobar. PhD student
Instituto de Tecnología Química (UPV-CSIC) Avda. de los Naranjos s/n 46022 Valencia (Spain)
Tfno: +34 96 387 7800 Fax: +34 96 387 9444
----- Terminar mensaje reenviado -----
*** *** *** *** *** *** *** *** ***
Cristina Alonso-Escobar. PhD student
Instituto de Tecnología Química (UPV-CSIC) Avda. de los Naranjos s/n 46022 Valencia (Spain)
Tfno: +34 96 387 7800 Fax: +34 96 387 9444
_______________________________________________ Ifeffit mailing list Ifeffit@millenia.cars.aps.anl.gov http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit
I wanted to add that you need a reasonable measure of confidence that these are the only paths contributing because otherwise you could receive negative values for a or b in the fit results if there are other paths involved by using this simple constraint. Chris ******************************************** Dr. Christopher Patridge Assistant Professor of Chemistry Math and Natural Science Dept BFAC 009 D'Youville College 320 Porter Ave., Buffalo, NY 14150 716-829-8096 Sent from my iPhone
On Feb 28, 2014, at 8:04 AM, Chris Patridge
wrote: Hi,
The easiest constraint would be a mathematical expression such as "a + b = 1". Do you have an experimental value for so2 as found for something chemically similar such as a standard at that edge? Then replace so2 expression for each path as "value found * a" and "value found * b". This should give a relative percentage for each path contribution.
Hope that is clear,
Chris
******************************************** Dr. Christopher Patridge Assistant Professor of Chemistry Math and Natural Science Dept BFAC 009 D'Youville College 320 Porter Ave., Buffalo, NY 14150 716-829-8096
Sent from my iPhone
On Feb 28, 2014, at 7:52 AM, Cristina Alonso Escobar
wrote: Dear All,
I am trying to fit the first FT shell in Artemis with a mixture of two different compounds (octahedral and tetrahedral models). I would like to quantify the ratio between this two compounds in my sample so I decided to multiply So2 by a parameter called "a" in one model and by "(1-a)" in the other.
I would like to know:
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.
Thank you in advance,
*** *** *** *** *** *** *** *** ***
Cristina Alonso-Escobar. PhD student
Instituto de Tecnología Química (UPV-CSIC) Avda. de los Naranjos s/n 46022 Valencia (Spain)
Tfno: +34 96 387 7800 Fax: +34 96 387 9444
----- Terminar mensaje reenviado -----
*** *** *** *** *** *** *** *** ***
Cristina Alonso-Escobar. PhD student
Instituto de Tecnología Química (UPV-CSIC) Avda. de los Naranjos s/n 46022 Valencia (Spain)
Tfno: +34 96 387 7800 Fax: +34 96 387 9444
_______________________________________________ Ifeffit mailing list Ifeffit@millenia.cars.aps.anl.gov http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit
_______________________________________________ Ifeffit mailing list Ifeffit@millenia.cars.aps.anl.gov http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit
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
participants (3)
-
Bruce Ravel
-
Chris Patridge
-
Cristina Alonso Escobar