help-octave
[Top][All Lists]

 From: Windhorn, Allen E [ACIM/LSA/MKT] Subject: RE: pade function in Octave? Date: Mon, 4 Nov 2019 22:17:43 +0000

```Vivek,

Let me say first that I know nothing about neutron spectroscopy, so I
obviously can't speak to the underlying science of what you are doing.
My thoughts are more involved with data analysis in general -- and I
don't even claim to be an expert on that.

> -----Original Message-----
> From: Help-octave On Behalf Of vivek guajri
>
> Yes, the fit function needs to be a polynomial. The reason is, we have
> some limited raw data ...  I am thinking to artificially produce more raw
> data by producing a polynomial that fits the limited raw data.

Hmm, but then this will be "fake" data, so it will be meaningless -- the
result has to be based on real data from an experiment, otherwise you
can prove anything [meaning nothing] with it.

I still don't see why it needs to be a polynomial.  You can "produce
more raw data by producing a FUNCTION that fits the limited raw data."
If there is a theoretical reason the data have to be polynomic, you
didn't explain it.

> If you look into my code, the first step I do, is to censor the raw
> data in ascending order and data less than 10. The first plot produced
> is the ascending order raw data and you can see its derivative at
> every point is greater than 0.

Of course it is -- you have sorted it so it is in ascending order.  That's the
definition of a positive derivative.  Why do you do this?  Apparently the
order of the y values is meaningless, so there is no use in plotting them --
they aren't points, just numbers.  And how do you justify discarding data
>10 arbitrarily?

The "X" values you are using are just fictitious equally-spaced values and
don't come from the measurements at all.  Why not use these instead:

x = [0.072113, 0.075038, 0.076368, 0.082951, 0.084015, 0.087506, ...
0.093058, 0.094986, 0.095352, 0.095618, 0.110280, 0.117561, ...
0.130527, 0.256566, 0.261055, 0.283596, 0.335960, 0.366979, ...
0.536439, 1.000000]

Now you can fit a very nice monotonic polynomial: AreaData = 9.1791x.

Or you could just use linear interpolation between points, that's
guaranteed to be non-decreasing.  But linear interpolation, or any kind
of curve fit for that matter, is based on a meaningful abscissa scale.

> Now, I want to produce a fit function using this plot and it has to be
> non-decreasing! This is the whole reason why I need the function to be
> non-decreasing! The function needs to be non-decreasing for all x!

Really all x?  Even negative x?  Otherwise a polynomial with only
positive coefficients will be monotonic.

> Why do you think polynomial is a bad fit?

Real world data seldom conforms to a polynomial -- even comets have
elliptical or hyperbolic orbits, not parabolic.  A polynomial always
wants to shoot off to infinity.  The more terms you put into it to try
and tame it, the worse it wants to shoot off once you let go of the
ends.  Real world stuff usually has a limit, or at least is asymptotic
to a line -- no polynomial was ever asymptotic to anything.

In your case, because it seems to be very difficult to make a polynomial
fit points, and still be monotonic -- polynomials want to wiggle and
they wiggle harder when you put in higher terms.

Polynomials are very popular because they are linear in the terms, so
they are VERY EASY to calculate a fit for and if you put in enough terms
you can always fit EVERY POINT.  What the function does between points
or past the ends isn't very reasonable though.  If you are fitting a
function to something, you should try to know in advance what sort of
function the data WANT to fit, and use that, or a close approximation.

Regards,
Allen
```