Message Boards Message Boards

0
|
5391 Views
|
10 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Using CurveFitReport on a set of numbers?

Posted 3 years ago

Hi, I have the data

data = {{-20, 2.52177*10^-13}, {-19, 1.2556*10^-12}, {-18, 
   6.24859*10^-12}, {-17, 3.10783*10^-11}, {-16, 
   1.54463*10^-10}, {-15, 7.67041*10^-10}, {-14, 3.80498*10^-9}, {-13,
    1.88499*10^-8}, {-12, 9.3224*10^-8}, {-11, 4.60029*10^-7}, {-10, 
   2.26336*10^-6}, {-9, 0.0000110902}, {-8, 0.000054019}, {-7, 
   0.000260758}, {-6, 0.00124029}, {-5, 0.00574344}, {-4, 
   0.0250746}, {-3, 0.0909159}, {-2, 0.275521}, {-1, 
   1.72721}, {0, -1.72721}, {1, -0.275521}, {2, -0.0909159}, {3, \
-0.0250746}, {4, -0.00574344}, {5, -0.00124029}, {6, -0.000260758}, \
{7, -0.000054019}, {8, -0.0000110902}, {9, -2.26336*10^-6}, {10, \
-4.60029*10^-7}, {11, -9.3224*10^-8}, {12, -1.88499*10^-8}, {13, \
-3.80498*10^-9}, {14, -7.67041*10^-10}, {15, -1.54463*10^-10}, {16, \
-3.10783*10^-11}, {17, -6.24859*10^-12}, {18, -1.2556*10^-12}, {19, \
-2.52177*10^-13}}

and use the command

ResourceFunction["CurveFitReport"][{data}, "Exponential"]

but it doesn't work.

What is wrong here?

Thanks!

POSTED BY: Ser Man
10 Replies
Posted 1 year ago

Take a look at

ListLogPlot[Abs[data1]]

Plot of the log of the absolute value

POSTED BY: Jim Baldwin

Yes, so this confirms my thought. So why does the author asks us to do a curve fit, while he knows which curve will fit?

Posted 1 year ago

I agree. The dataset seems contrived as it is perfectly symmetric about -1/2:

data[[1 ;; 20, 2]] == -data[[Range[40, 21, -1], 2]]
(* True *)

ListLogPlot[Transpose[{data[[All, 1]], Abs[data[[All, 2]]]}]]

Plot of data on a log scale

Maybe this was a question on an exam.

POSTED BY: Jim Baldwin

When I look closer, I must conclude that the data were calculated, not measured, so you must have a formula to describe them?

Posted 1 year ago

Could you tell use what was measured here? That might give us some idea about the model function!

POSTED BY: Updating Name
Posted 3 years ago

Not sure what you mean by

but neither work

ResourceFunction["CurveFitReport"][data, x, "Exponential"]
ResourceFunction["CurveFitReport"][data1, x, "Exponential"]

Both return a reasonable fit.

POSTED BY: Rohit Namjoshi
Posted 3 years ago

The first set works for me too. But I get for the second set:

LinearModelFit::notdata: The first argument is not a vector, matrix, or a list containing a design matrix and response vector.
POSTED BY: Ser Man
Posted 3 years ago

That looks like a bug in CurveFitReport, you should report it.

fm = NonlinearModelFit[data1, a Exp[b x], {a, b}, x]
Show[Plot[fm[x], {x, 0, 19}, PlotRange -> All], ListPlot[data1, PlotStyle -> Red]]

enter image description here

AssociationMap[fm, fm["Properties"]] // Dataset

enter image description here

POSTED BY: Rohit Namjoshi
Posted 3 years ago

I tried to split int two sets:

data =   {{-20, 2.52177*10^-13}, {-19, 1.2556*10^-12}, {-18, 
6.24859*10^-12}, {-17, 3.10783*10^-11}, {-16, 
1.54463*10^-10}, {-15, 7.67041*10^-10}, {-14, 3.80498*10^-9}, {-13,
1.88499*10^-8}, {-12, 9.3224*10^-8}, {-11, 4.60029*10^-7}, {-10, 
2.26336*10^-6}, {-9, 0.0000110902}, {-8, 0.000054019}, {-7, 
0.000260758}, {-6, 0.00124029}, {-5, 0.00574344}, {-4, 
0.0250746}, {-3, 0.0909159}, {-2, 0.275521}, {-1, 
1.72721} }

data1 = {  {0, -1.72721}, {1, -0.275521}, {2, -0.0909159}, {3, 
-0.0250746}, {4, -0.00574344}, {5, -0.00124029}, {6, -0.000260758}, 
{7, -0.000054019}, {8, -0.0000110902}, {9, -2.26336*10^-6}, {10, 
-4.60029*10^-7}, {11, -9.3224*10^-8}, {12, -1.88499*10^-8}, {13, 
-3.80498*10^-9}, {14, -7.67041*10^-10}, {15, -1.54463*10^-10}, {16, 
-3.10783*10^-11}, {17, -6.24859*10^-12}, {18, -1.2556*10^-12}, {19, 
-2.52177*10^-13}}

but neither work, although they are clearly exponential.

POSTED BY: Ser Man
Posted 3 years ago

The fit variable is missing

ResourceFunction["CurveFitReport"][data, x, "Exponential"]

The data is clearly not described by a simple exponential and is discontinuous. You will have to use NonLinearModelFit and your knowledge of what the data represents to define a function to fit.

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract