COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### MPFIT2DPEAK with constraints

• Email
• Follow

```Greetings. I'm trying to understand how Craig
Markwardt's peak fitting function MPFIT2DPEAK
works when you wish to require that certain
parameters be held constant.

Specifically, I know that my data should peak
at the origin and so I'd like to force the
fitted Gaussian to peak there as well.

Despite specifying that A[4] and A[5] be
fixed using the PARINFO structure, the fitted
Gaussian is not centered at the origin.
Supplying PARINFO to MPFIT2DPEAK does change
the fit but it actually makes it slighly worse.
Anyone know what I might be doing wrong?

Here's my sample code:

;------------------------------------------------
; Construct a sample gaussian surface in range [-5,5] centered at
[0,0]
x = findgen(100)*0.1 - 5. & y = x
xx = x # (y*0 + 1)
yy = (x*0 + 1) # y
rr = sqrt((xx-0*2.)^2 + (yy+0*3.)^2)

; Gaussian surface with sigma=0.5, peak value of 3, noise with
sigma=0.2
seed=6
z = 3.*exp(-(rr/0.5)^2) + randomn(seed,100,100)*.2

pi = replicate({value:0.D, fixed:0, limited:[0,0], \$
limits:[0.D,0]}, 7)

pi(4).fixed = 1
pi(5).fixed = 1

a0=[0., 3., 1.0, 1.0, 0.0, 0.0, 0.0]
pi(*).value = a0

; Fit gaussian parameters A
zfit = mpfit2dpeak(z, a1, x, y, /tilt, PARINFO=pi)

zfit = mpfit2dpeak(z, a2, x, y, /tilt)

print,a1
print,a2
------------------------------------------------

IDL prints:

a1=[-0.000156282, 2.82180, 0.382853, 0.347286, -0.0999999, 0.0999999,
0.716917]

a2=[-0.000266513, 3.06073, 0.345753, 0.351519, -0.000407959,
0.00455947,     1.98130]
```
 0
Reply c.carrano (3) 10/9/2003 10:40:07 PM

See related articles to this posting

```c.carrano@att.net (Charles Carrano) writes:
> Greetings. I'm trying to understand how Craig
> Markwardt's peak fitting function MPFIT2DPEAK
> works when you wish to require that certain
> parameters be held constant.
>
> Specifically, I know that my data should peak
> at the origin and so I'd like to force the
> fitted Gaussian to peak there as well.
>
> Despite specifying that A[4] and A[5] be
> fixed using the PARINFO structure, the fitted
> Gaussian is not centered at the origin.
> Supplying PARINFO to MPFIT2DPEAK does change
> the fit but it actually makes it slighly worse.
> Anyone know what I might be doing wrong?

Greetings--

>    zfit = mpfit2dpeak(z, a1, x, y, /tilt, PARINFO=pi)

The documented way to enter the initial parameters to MPFIT2DPEAK is
using the ESTIMATES keyword.

Craig

--
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D.      EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------
```
 0
Reply craigmnet (368) 10/10/2003 3:00:26 AM

```Craig Markwardt <craigmnet@REMOVEcow.physics.wisc.edu> wrote in message news:<onzng9lrud.fsf@cow.physics.wisc.edu>...
> c.carrano@att.net (Charles Carrano) writes:
> > Greetings. I'm trying to understand how Craig
> > Markwardt's peak fitting function MPFIT2DPEAK
> > works when you wish to require that certain
> > parameters be held constant.
> >
> > Specifically, I know that my data should peak
> > at the origin and so I'd like to force the
> > fitted Gaussian to peak there as well.
> >
> > Despite specifying that A[4] and A[5] be
> > fixed using the PARINFO structure, the fitted
> > Gaussian is not centered at the origin.
> > Supplying PARINFO to MPFIT2DPEAK does change
> > the fit but it actually makes it slighly worse.
> > Anyone know what I might be doing wrong?
>
> Greetings--
>
> >    zfit = mpfit2dpeak(z, a1, x, y, /tilt, PARINFO=pi)
>
> The documented way to enter the initial parameters to MPFIT2DPEAK is
> using the ESTIMATES keyword.
>
> Craig

Thank you. I had inadvertently confused the functions
of the parinfo.value and ESTIMATES parameters. Passing
ESTIMATES=a0 to mpfit2dpeak fixes the sample code
above. Thank you for your help and, of course, your
valuable software contribution to the scientific
community.

- Charles
```
 0
Reply c.carrano (3) 10/10/2003 2:51:18 PM

2 Replies
85 Views

Similar Articles

12/8/2013 4:29:16 PM
page loaded in 156684 ms. (0)

Similar Artilces:

Hi, I have been using fmincon below to do a non-linear optimisation: M = fmincon(optfunc2,C,[],[],[],[],repmat(-20,12,9),repmat(20,12,9),@TriskellCoefficients); @TriskellCoefficients places a limit on the stdev of C: function [c,ceq]=TriskellCoefficients(X) c(1) = mean(std(X))-5; ceq = []; end My question: My objective function returns 2 values, total return and stdev of returns. If I am maximising my returns, where do I set the contraint to keep stdev to below a certain value? Thanks, Eduard

Help with constraints
Hello : Im trying to setup a constraint between two tables in Oracle 9 TABLE_A has a column( number ) named ROLE_ID TABLE_B has three columns named ROLE_KEY, REGION and COMPANY I want to set up a constraint on TABLE_A so that user can only insert ROLE_IDs such that all the following three conditions are met 1. the value of ROLE_ID should be equal to one of teh existing values of ROLE_KEY from TABLE_B 2. REGION='US' ( REGION value for teh matching ROLE_KEY should be US ) 3. COMPANY='ABCD' ( COMPANY value for teh matching ROLE_KEY should be ABCD ) In other words... The ROLE

integer constraints
All, I have a function 'total_loss = get_system_loss(cap,invbus,rectbus)' which i want to minimize using GA. The input parameters should be integers. How do i constraint GA such that the population is composed of integers only? Thanks. jem "jem " <jeramymendoza@gmail.com> wrote in message <ih8o64\$sjj\$1@fred.mathworks.com>... > All, > > I have a function 'total_loss = get_system_loss(cap,invbus,rectbus)' which i want to minimize using GA. The input parameters should be integers. How do i constraint GA such that the population is comp

Naming DEFAULT constraints
Hi, I am attempting to rename all of the DEFAULT constraints in a database so that they have controlled names (i.e. not system generated one). My plan was to find the system generated name, drop the constraint then recreate it. I cannot seem to find a way of creating a named default constraint on a colum. I have tried: ALTER TABLE <TABLE NAME> ADD CONSTRAINT DF1_<TABLE NAME> DEFAULT <VALUE> (<COLUMN>); This fails I have also tried: ALTER TABLE <TABLE_NAME> MODIFY (<COLUMN_NAME> DEFAULT DF1<TABLE_NAME> <VALUE>; Neither work and I am unsure why. Does anybody know if this is possible and if so how I can acheive it. It is not good enough just to be able to rename the existing constraint as I need to be able to add new named ones in the future. If anybody can suggest anything it would be greatly appreciated. Thanks in advance, Paul On Jan 26, 9:09 pm, "Paul" <paulwragg2...@hotmail.com> wrote: > Hi, > > I am attempting to rename all of the DEFAULT constraints in a database > so that they have controlled names (i.e. not system generated one). > Refer to instructions on how to rename

Image Acquisition: Property constraints
Give that my camera is identifed as "vid" and the source object is "source", when trying to take numerous pictures, with MATLAB automatically adjusting the property of Gain by increments of 100, I use: for i=350:700; source.Gain = source.Gain + 100 snapshot=getsnapshot(vid); I get the error: Error using ==> set Gain: Property value can not be set above the maximum value constraint. See PROPINFO(OBJ, 'PROPERTY') ....so I: propinfo(source, 'Gain') Type: 'double' Constraints: 'bounded' ConstraintValue: [350 1023] DefaultValue: 350 ReadOnly: 'never' DeviceSpecific: 1 ....so I'm obviously in between the constraints of 350 and 1023. Why do I get the error? Any help would be appreciated. J.Meyer wrote: > Give that my camera is identifed as "vid" and the source object is > "source", when trying to take numerous pictures, with MATLAB > automatically adjusting the property of Gain by increments of 100, I > use: > > for i=350:700; > source.Gain = source.Gain + 100 > snapshot=getsnapshot(vid); > > I get the error: > Error using ==> set > Gain: Property

Occurence constraints in XSD
hi all having designed my schema to use repeating groups of elements, I found that some applications (eg. Microsoft InfoPath) refused to recognised that element as a repeating element. I subsequently found that out of the three possible ways (that I know of) of declaring repeating elements in xsd, only one of these was understood: a) occurence constraint on the child element contained in a sequence compositor IS recognised as a repeating element. b) occurence constraint on sequence compositor containing the child element IS NOT recognised as a repeating element. c) occurence constraint on g

Timing constraints on ISERDES
Using the ISERDES primitive in Virtex 4 in DDR mode (for data input from an ADC), what timing constraints should be applied? In particular, I want to know the maximum data update rate (or alternatively, maximum source-synchronous clock frequency) that can be used to get the data into the FPGA. I assume this is limited by pin capacitance or other physical constraints, but don't know what it is in my design. For example, say I have a single data input DATA and a single source-synchronous clock CLK (both of which come from the ADC). They are both LVDS, so I used IBUFDS. Both enter separate ISERDES. I use the "direct" combinatorial output of the CLK ISERDES (O) to feed a BUFIO, the output of which becomes the CLK for both ISERDES. This also feeds a BUFR with /2 divider, which feeds CLKDIV on both. I then get 4 demultiplexed outputs of DATA Q0-3, which can then feed a FIFO or DSP core. So far I have applied a clock frequency constraint to the O output of the CLK ISERDES, and that is all. But the timing analyser only seems to check the CLKDIV constraints for the data outputs in the cores that follow, not the ISERDES itself... Any enlightenment would be much appreciated

Boolean constraints in plot functions
Hello, Now that we have "arbitrary plotting regions" in Mathematica 6, would it not be more natural (and easier) to allow for arbitray Boolean combinations in plot functions? (Consider RegionPlot.) For example, instead of Plot[f[x], {x, a, b}, RegionFunction -> Function[{x, y}, ineq] ] it should be possible to simply write Plot[f[x] && ineq, {x, a, b}] Well, to my surprise, I just discovered that this works (even in Mathematica 5.1)! Example: Plot[x^2 && -1 < x < 1, {x, -4, 4}, PlotRange -> {-4, 4}] However, it doest not work for

Help with constraints on object relational tables
constraints on these columns to say: ----- Manager: check the person_number is less than 20000 ----- Applicant: check the person_number is greater than 19999 Can anyone tell me if this is possible and if so how can it be done? Thanks in advance Stephen Stephen Reid wrote: > Hi > > I hope I am posting in the correct places. I am looking for some help that > is hopefully explained in the example below: > > I am looking to create an object relational database with a check constraint > on the relationships. For example: > > * I have table called person_tab which is a table of person_t type. > * Person_t type is inherited by the manager_t type and the applicant_t type. > * I have a second table called interview_tab of interview_t type. > * The interview table has two columns (manager and appilcant) that are scope > restrained to the person table. > * I would also like to put check constraints on these columns to say: > ----- Manager: check the person_number is less than 20000 > ----- Applicant: check the person_number is greater than 19999 > > Can anyone tell me if this is possible and if so how can it be done? > >

How to plot a function subject to constraints
Is there a way to plot a function: R^2 -> R subject to one or more constraints? For example I'd like to plot the function: f(x, y) = x + y^2 where (x, y) � R^2: x >= x^2, x^2 + y^2 <= 2 Thanks! Opss! I wrote x instead of y :) > (x, y) � R^2: x >= y^2, x^2 + y^2 <= 2 ^ "Luca D." <ldantona@gmail.com> wrote in message news:ela2sn\$it5\$1@aioe.org... > Is there a way to plot a function: R^2 -> R subject to one or more > constraints? > For example I'd like to plot the function: > f(x, y) = x + y^2 > where > (x, y) � R^2: x >= x^2, x^2 + y^2 <= 2 > Thanks! % Spacing in x and y directions - adjustable dx = 0.01; dy = 0.01; % Generate a grid of XY points [xm, ym] = meshgrid(-2:dx:2, -2:dy:2); % Evaluate the function on the grid f = xm + ym.^2; % Any point that doesn't satisfy the constraints becomes NaN f(xm < xm.^2) = NaN; f(hypot(xm, ym).^2 > 2) = NaN; % Surf plot the function -- NaNs aren't displayed surf(xm, ym, f, 'EdgeColor', 'none') Alternately, if you don't want to negate the constraints on the plotting region: % Spacing in x and y