Items tagged with fit fit Tagged Items Feed

Hello

I am working on a project where I need to find the parameters of the formula:

1/2*a*erfc(1/2*2^(1/2)*(-x+m1)/s1)+(1/2-1/2*a)*erfc(1/2*2^(1/2)*(-x+m2)/s2)

which is the formula for the cumulative distribution for two gaussian peaks, one with average m1 and standard deviation s1, the other m2 and s2, with weights a and (1-a). I have data in excel that form the gaussian distribution but now I need to find the parameters of the formula that fits these data.

Is there a command in maple to find these parameters or how do I start? And do I need to upload the data from excel to maple or do I need to insert only some values?

Some one who could help me, because it is really hard and I find no information for this.

Hasselhof

loock i have 3 models and a Matrix
>m3:=importmatrix("loslobos.txt");
>model[1]:=a*x;
>model[2]:=a^2*x+b;
>model[3]:=C-x^2+a;

so i apply a command named DataFit and it gives me 
>g:=Datafit(matrix,model[1]);

and that throws
         g:=[3,[a:=5],33];
so
         >g[1];
3
         >g[2];
5
         >g[3];
33
the variable that i care about is g[1] so every 3 models have differents g[1] so i need to pick the smallest g[1] and then use his model.
Example:=
>g:=Datafit(matrix,model[1]);
g:=[3,[a:=5],33];
>gg:=Datafit(matrix,model[2]);
gg:=[10,[a:=5,b:=10],44];
>G:=Datafit(matrix,model[3]);
G:=[1.1,[C:=5,a:=2],88];

then 

>plots:-display(plot(m3, style = point, symbol = diamond, symbolsize = 9), plot(eval("MODEL THAT SHOULD BE PLOT", THE G[2] OF THE MODEL), x = 0 .. 27, color = black));

The right one here would be 

>plots:-display(plot(m3, style = point, symbol = diamond, symbolsize = 9), plot(eval(model[3], G[2]), x = 0 .. 27, color = black));

so how do i select the model[3] for my plot? i knnow how the eval works so the problem here is to pick the right model please Help i hope that i isn't that Hard thnx
   

Hi, I solved some equations those days and get a group of data, namely, Data1. Then I want to get the function of the data, so I use the CurveFitting package of maple, and get the function easily (the function seems as a*x^3+b*x^2+c*x+d). But the function is not the one I really wanted, because it is hard to generate the complex curve (even the function is known) in some software. 

As I know, it is easily to generate some arcs in the software, so is there any way to fit a group of data with some piecewise of arcs?

 Best regards.

Data1:= [[.690499054221957, .109364306247567], [.679584570047867, 0.955093827253927e-1], [.668476295825779, 0.820785684569687e-1], [.657171143364362, 0.690714704619819e-1], [.645665768347822, 0.564884351571898e-1], [.633956566493958, 0.443305616055764e-1], [.622039668654294, 0.325997176601303e-1], [.609910934797136, 0.212985591645471e-1], [.597565946804089, 0.104305524003572e-1], [.585, 0], [.572208093323944, -0.998792942142104e-2], [.559184918035503, -0.195271676259796e-1], [.545924844835652, -0.286107087732754e-1], [.532421909264435, -0.372305667237386e-1], [.518669795218710, -0.453777271949494e-1], [.504661816411590, -0.530420942817277e-1], [.490390895570740, -0.602124307834357e-1], [.475849541144774, -0.668762917052363e-1], [.461029821255068, -0.730199502124052e-1]]

Maple 18.02 on windows. A 4 by 4 matrix, does not display on the screen in nice formating when it has too many elements to fit current screen. But I'd like it to be displayed in 2D just like all the other 4 by 4 matrices and then use the horizontal scroll bar if needed to see the full matrix. Is this possible?

------------------------------------

restart;
z:=theta__1:
T01:=Matrix([
[cos(z),   0,   sin(z),   L*cos(z)],
[-sin(z),  0,  -cos(z),   L*sin(z)],
[0,         1,  0,          0],
[0,         0,  0,          1]]):

z:=theta__2:
T12:=Matrix([
[cos(z),    0,   -sin(z),   L*cos(z)],
[sin(z),    0,    cos(z),   L*sin(z)],
[0,         1,  0,          0],
[0,         0,  0,          1]]):

z:=theta__3:
T23:=Matrix([
[cos(z),    0,   -sin(z),   L*cos(z)],
[sin(z),    0,    cos(z),   L*sin(z)],
[0,         -1,  0,          0],
[0,         0,  0,          1]]):

T02   := T01.T12;
T03   := T02.T23;
LinearAlgebra[Dimension](T03);
------------------------------------------------

T02 above displays in 2D fine. But T03 does not on standard 100% zoom on my monitor. Screen shot:

When I changed the zoom to 50%, now it did format ok on the screen:

May be I need a way to activate the horizontal screel bar? I really do not want to keep changing zoom each time I want to see a larger matrix. All the matrices are 4 by 4, but some of them can end up with many terms in each entry.

I'm wondering why the fit routine gives weird results, when telling him to fit

with(Statistics):

X:=Vector[column](3, {1 = 616.3096, 2 = 616.3248, 3 = 616.3342}, datatype = sfloat, storage = rectangular, order = Fortran_order, shape = []);

Y:=Vector[column](3, {1 = 99590., 2 = 127564., 3 = 144223.}, datatype = sfloat, storage = rectangular, order = Fortran_order, shape = []);

g:=Fit(a+b*x+c*x^2,X,Y,x)

It's telling me: Warning, model is not of full rank

If I calculate the coefficients the direct way (well the fit should be exact,because we only have 3 values and 3 parameters) I get:

M:=Matrix(3, 3, {(1, 1) = 1, (1, 2) = 616.3096, (1, 3) = 379837.52305216, (2, 1) = 1, (2, 2) = 616.3248, (2, 3) = 379856.25909504, (3, 1) = 1, (3, 2) = 616.3342, (3, 3) = 379867.84608964}, datatype = anything, storage = rectangular, order = Fortran_order, shape = []);
V:=Vector[column](3, {1 = 99590, 2 = 127564, 3 = 144223}, datatype = anything, storage = rectangular, order = Fortran_order, shape = []);
with(LinearAlgebra):
C:=MatrixVectorMultiply(M^-1,V)

 

I am fitting polynomial differential equations to data, and I came across some troubling behavior. I have sets of coordinates in x, y, z, and values w at these coordinates. The x,y,z coordinates and the data at these coordinates are concatenations of three subsets of data each, and depending on the order of the concatenation, I get different polynomials from the stats fit command. The difference is not trivial -- it makes a huge differentce in the stability of the differential equations. I have written a demonstration worksheet to show this problem.

John Starrett

Hi I am working on the following problem (See below the line) from the text A Introduction to the Mathematics of Biology (Ch 2 pgs.21-23). I am working in Maple 18 and the code for this problem is from Maple 11 I think. If you look at the last line of code, I ran into a snag. Can anyone help????? We are in a study Gourp and alll are stumped.

_______________________________________________________________________________________________________

Problem # 2 - Find a fit for the cumulative US AIDS data as a polynomial function. Alsoo find an exponential fit for the data. (assume the Data I have inputed is correct if you don't have the book).

AIDS := [97, 206, 406, 700, 1289, 1654, 2576, 3392, 4922, 6343, 8359, 9968, 12990, 14397, 16604, 17124, 19585, 19707, 21392, 20846, 23690, 24610, 26228, 22768];
print(`output redirected...`); # input placeholder
[97, 206, 406, 700, 1289, 1654, 2576, 3392, 4922, 6343, 8359,

9968, 12990, 14397, 16604, 17124, 19585, 19707, 21392, 20846,

23690, 24610, 26228, 22768]

CAC := [seq(sum(AIDS[j]/(1000.0), j = 1 .. i), i = 1 .. 24)];
print(`output redirected...`); # input placeholder
[0.09700000000, 0.3030000000, 0.7090000000, 1.409000000,

2.698000000, 4.352000000, 6.928000000, 10.32000000,

15.24200000, 21.58500000, 29.94400000, 39.91200000,

52.90200000, 67.29900000, 83.90300000, 101.0270000,

120.6120000, 140.3190000, 161.7110000, 182.5570000,

206.2470000, 230.8570000, 257.0850000, 279.8530000]


Time := [seq(1981+(i-1)*(1/2), i = 1 .. 24)];
ln(CAC)=k*lnt+A
LnCAC := map(ln, CAC);
print(`output redirected...`); # input placeholder
[-2.333044300, -1.194022473, -0.3438997525, 0.3428802329,

0.9925107578, 1.470635510, 1.935571171, 2.334083760,

2.724054775, 3.071998629, 3.399328971, 3.686677031,

3.968441145, 4.209145378, 4.429661370, 4.615387808,

4.792578782, 4.943918402, 5.085810791, 5.207062453,

5.329074480, 5.441798471, 5.549406770, 5.634264465]
LnTime := map(ln, [seq((i+1)/(2*(1/10)), i = 1 .. 24)]);
print(`output redirected...`); # input placeholder
[ln(10), ln(15), ln(20), 2 ln(5), ln(30), ln(35), ln(40), ln(45),

ln(50), ln(55), ln(60), ln(65), ln(70), ln(75), ln(80), ln(85),

ln(90), ln(95), 2 ln(10), ln(105), ln(110), ln(115), ln(120),

3 ln(5)]
with(stats);
fit[leastsquare[[x, y], y = k*x+lnA]]([LnTime, LnCAC]);
print(`output redirected...`); # input placeholder
y = 3.293411005 x - 10.12289000
k := op(1, op(1, rhs(%))); LnA := op(2, rhs(`%%`)); A := exp(LnA);
print(`output redirected...`); # input placeholder
Error, invalid input: rhs received exp(LnA), which is not valid for its 1st argument, expr
Error, invalid input: rhs received exp(LnA), which is not valid for its 1st argument, expr
exp(LnA)

From some scientific experiments, the following set of data is available
(1.0, 2.33),(2.0, 0.0626),(3.0, −2.16),(4.0, −2.45),(5.0, −0.357),(6.0, 2.21),(7.0, 2.75),(8.0, 0.636),(9.0, −2.45).

We need to use least squares method to fit the curve to the data
y = a + b cos(x) + c sin(x) + d cos(2x) + e sin(2x)


Show your solution procedure in Maple and get the best fit for the coefficients. Finally
plot the data and the y curve together on the same graph to visualize the fitting. For the
data, use blue circles while for the y curve, use red solid line style. Use the leastsquares
command we learned in LinearAlgebra package.

Hello everyone,

I'm trying to do some fitting using NonlinearFit, for the coefficients I know in advance, that they have to fulfill a condition (a+b>c+1). I couldn't find a way to make Maple take this condition into consideration while fitting my data. I tried to use Parameterrange to make the difference a+b-c+1 positive, this works for linear conditions like mine but leads to computational difficulties and errors like "no improved point could be found".

Thanks in advance,

Sören

i have a non linear equation that depends on three variables e, theta and z.

i have done calculations to calculate e while varying theta and z. theta varied among the vector [0, Pi/4, Pi/3, Pi/2] and z was varying between 1 and 20

when plotting my data it gives the following plot where z is represented on the x-axis and each curve correspond to one theta

 

i am currently able of fitting one plot to one equation i would like to fit the data points using the nonlinearfit function and to only get one equation for all the plots. is that possible in maple or not

 

Hi everyone,

I have a question about surface fitting. I tried to follow the step of application "Fitting an Ellipse to Data" to fit the ellipsoid surface but got the incorrect result:

 

 

It seems that the convergence condition can be modified but I have no idea. 

The related Maple file is attached:

Ellipsoid_Surface_Fitting.mw

I'd appreciate any help on this topic. Thank a lot.

Hello everyone!

I have a question that I can't seem to find a straight answer to. I need to fit a circle to a collection of points that a circular in nature. I was trying to use the following elliptical least squares fit, but I can't determine what I should be minimizing.

Here's the page:

http://www.maplesoft.com/applications/view.aspx?SID=1395&view=html

 

For an ellipse, I used the general conic:

F:=a*x^2+b*x*y+c*y^2+d*x+e*y+f

I minimize using:

V:=Minimize(E,{4*a*c-b^2=1});

 

What would I use for a circle? Or is there a better way for a circle?

Hi

 

I have some data:

Matrix(10, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = .5, (2, 2) = 3.25, (3, 1) = 1.0, (3, 2) = 5.82, (4, 1) = 1.5, (4, 2) = 7.50, (5, 1) = 2.0, (5, 2) = 8.79, (6, 1) = 2.5, (6, 2) = 9.83, (7, 1) = 3.0, (7, 2) = 10.66, (8, 1) = 3.5, (8, 2) = 11.35, (9, 1) = 4.0, (9, 2) = 11.94, (10, 1) = 4.5, (10, 2) = 12.46})

 

I want Maple to make a trendline fitting a Logarithmic function. I can make it output some function with this:

LeastSquares(`<,>`(.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5), `<,>`(3.25, 5.82, 7.50, 8.79, 9.83, 10.66, 11.35, 11.94, 12.46), x, curve = a+b*ln(x))

It outputs:

5.96497783539274+4.25309474196387*ln(x)

 

But please notice, the dataset in the function does not have the first 0 and 0. If i do that:

LeastSquares(`<,>`(0, .5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5), `<,>`(0, 3.25, 5.82, 7.50, 8.79, 9.83, 10.66, 11.35, 11.94, 12.46), x, curve = a+b*ln(x))

It outputs: 

Error, (in Matrix) numeric exception: division by zero

 

Besides that, i need the R-squard value for determinating how well it fits.

 

If i do the same thing i Excel the data set will give a formular: 5.5464ln(x)-0.2175 with a R-sward value of 0.9985.

 

How can i do this i maple?

 

Thanks in Advance!

 

----

Emil Kristensen

Hi there!

I wrote a piece of code which spits out the numerical datapoints (x,y(x)) corresponding to a function y(x). So that the result is accurate, I need quite a lot of data points - currently I am working with 5k.

In order to work with this function later, I interpolated it with a Spline. For instance, I would like to sample the function values on a fifferent grid, etc.. However the evaluation of this function really takes up hell of a lot of time, and the reason seems to be, that it, being a spline on 5k nodes, is simply a huge expression.

Is there a better way to do this? Are other fitting functions than a spline maybe better suited?

Thanks for help!

 

1 2 3 4 Page 1 of 4