Fit a curve based on its area?
Show older comments
Hi everyone! Basically, I need to estimate a curve based on its integral. I don't know the actual function.
I know my x values will be (0:1000). I know the area when x = 0:30 is 10% of the total area, x = 0:60 is 50% and x = 0:80 is 90%.
I have no idea where to start! I have tried using curve fitting tools but didn't succeed. Can someone help me with that?
Cheers!
13 Comments
David Goodmanson
on 17 Jan 2017
Hello Larissa, if that is all the information you have there are an unlimited number of possible functions. If the domain of the function is really 1:1000 and not 1:100, given that 90% of the integral occurs by x = 80, that would argue that the function might (might!) feature a decreasing exponential, something like (a+bx+cx^2)e^(-gx). But without imposing some kind of functional form you can't make any progress at all.
Larissa Perez
on 18 Jan 2017
Walter Roberson
on 18 Jan 2017
Small details like that are important...
Larissa Perez
on 18 Jan 2017
David Goodmanson
on 18 Jan 2017
do you know if the function is zero for x<0, or does it extend into negative values of x?
Larissa Perez
on 18 Jan 2017
Larissa Perez
on 18 Jan 2017
Edited: Larissa Perez
on 18 Jan 2017
David Goodmanson
on 18 Jan 2017
I'm not saying this is the function, but does its shape look somewhat like
x = 0:.01:10;
y = x.*exp(-x);
plot(x,y)
Larissa Perez
on 18 Jan 2017
David Goodmanson
on 18 Jan 2017
Well, the problem now is that you have four conditions, assuming you are confident that the peak is right at x = 60. That means you have to fit an equation with four adjustable parameters. Walter has a solution technique, but so far it assumes a straight polynomial fit. The most obvious four parameter solution that has the shape you are talking about would be (ax + by^2 + cy^3)exp(-gy) [or, because of the nature of the conditions, (x + by^2 + cy^3 + dy^4))exp(-gy) might be needed, I haven't quite figured out which ].
There would be work involved to fit that, especially the coefficient g. If you knew g, which you don't, it would be a lot easier. Someone may have some tricks up his/her sleeve here. But it's a hard enough problem that it makes sense to ask, what is the context here? Are the conditions exact or pretty good but approximate? Is a not so simple many-parameter fit the way to go? Do you have any other information about where this function came from that might indicate what kind of function it is? Is the goal to do interpolation to find the area at other values of x?
Larissa Perez
on 18 Jan 2017
David Goodmanson
on 18 Jan 2017
Edited: David Goodmanson
on 18 Jan 2017
Your best bet here may be the log normal distribution which is often used for particle sizes and a lot of other situations. You assume the log of particle size is normally distributed. For a good fit, log of the d50 size should be right in between log of the d10 size and log of the d90 size. So log(60) should be halfway between log(33) and log(95). Those three values are
ans = 3.4965 4.0943 4.5539
and not equally spaced. But fitting those three points with a straight line may be the best you can do. That fit is pretty decent, not super.
Larissa Perez
on 19 Jan 2017
Answers (1)
Walter Roberson
on 17 Jan 2017
Edited: Walter Roberson
on 17 Jan 2017
one of the solutions is
syms a b c d e F(x) f(x)
F(x) = a*x^4+b*x^3+c*x^2+d*x+e
sol = solve([F(30)-F(0)==10,F(60)-F(0)==50,F(80)-F(0)==90,F(1000)-F(0)==100])
f(x) = subs(diff(F(x),x),{a,b,c,d},{sol.a,sol.b,sol.c,sol.d})
For each additional known point you have, add another term to F(x) and add the point to the solve() expression.
This is based upon the fact that the indefinite integral is taken and becomes an actual function, and that the definite integral is determined by the subtraction of the value of the indefinite integral at the end points. F(x) is acting as the indefinite integral. You can then create simultaneous equations out of it and solve for the coefficients. Then substitute those into the derivative of F(x) to get the original f(x)
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!