2 views (last 30 days)

Show older comments

Dear MATLAB experts,

I'm struggling here to solve a problem with the following characteristics:

I've a file containing a huge column of data, which I order in a histogram, let's call it . Afterwards, I would like to sum the histogram, starting everytime from a different point , that is:

I have an experimentally measured value and I would like to find then which best fits to the experimental value. I have basically calculated:

and then fitted it with a known function to calculate the derivative and estimate the minimum.

In the real problem I have actually three experimental values, so that has actually three terms, and afterwards I would like to include even more parameters apart from . As you can imagine, the script I've written for this is extremely time consuming, and I'm not even sure that this procedure is correct/optimal.

So, it feels like I'm doing the minimization procedure by hand, and surely there are better tools for posing such a problem. Are any of you aware of, which tool could better fit my needs? I've seen already stuff like patternsearch, fminunc, etc, but they all need a definite function which I do not have.

Any help would be very much appreciated.

Thank you all in advance.

Cheers

Alan Weiss
on 5 May 2021

I'm not sure that I understand what you are doing, but I think that you could use the fminbnd solver along with some interpolation or floor or ceiling function.

First, compute all of the tail sums. I assume that your psi vector is a row vector.

tails = cumsum(fliplr(psi));

tails = fliplr(psi);

If I am right, tails(1) is now the sum of all of the elements in psi, and tails(end) is psi(nmax).

Now to look for the element of tails that best matches your criterion, do fminbnd on the function

fun = @(x)tails(floor(x));

Well, you put in your criterion, but you see that fun takes a continuous argument and immediately takes the floor of that argument so it is only working on integers.

I think that you can take it from here. Good luck,

Alan Weiss

MATLAB mathematical toolbox documentation

Alan Weiss
on 6 May 2021

I think that you would do best with functions that do not rely on smoothness. In particular, patternsearch from Global Optimization Toolbox would be my first choice for this problem in multiple dimensions. You can easily set a stopping criterion of a mesh size of less than 1, and set an initial mesh size of more than 1.

I do not recomment fminsearch for this problem. It has the same behavioral deficiency as fminunc: it is unlikely to move from an initial point, or could easily get fooled and stuck by the local flatness. Also, it could step out of bounds, and then I am not sure what would happen. I strongly recommend fminbnd as the solver of choice in 1 dimension for testing before you move to higher dimensions.

Alan Weiss

MATLAB mathematical toolbox documentation

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!