Carl Love

Carl Love

28055 Reputation

25 Badges

12 years, 362 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@acer 

Yes, I agree with Acer 100%. I did know that the minima from different fitmethods weren't directly comparable (however, the minima from different methods using one fitmethod are comparable), but I was being lazy and ad hoc in my minimum-selection process. So I knew that I'd have to look at the plots also.

A more formal approach would be to take all the minimal parameter combinations returned and measure them with a single objective function that makes sense for the application. This occasionally produces a lower value than the point returned as the minimum for that objective. How can that be? No known method of minimizing a nonconvex function can guarantee that it has found the global minimum; only local minima can be guaranteed.

There are several other reasonable selection approaches. All that I can think of involve some degree of hueristics.

 

@hasselhof 

I recommend that you download the DirectSearch package and read its extensive help files in addition to reading this. Depending on your Maple version, you may need to convert the help files to the new format, which is very easy to do.

DirectSearch:-DataFit offers nine ways to measure the residuals. These are the fitmethods. For example, lms is Least Mean Squares---the most traditional way---and lad is Least Absolute Deviations---probably the most intuitive way. Each of these leads to an objective function that is to be minimized. DirectSearch as a whole offers four algorithms for approximating the minimum of a function. These are the methods. That's a total of 9 x 4 = 36 methods. Using other options to DataFit, I could get even more.

The output of DataFit is a three-element list. The first element is the minimal achieved value of the objective function. The second element is, of course, the list of parameter values at which that minimum is achieved. The third element (which has no significance here) is the number of times the objective function was evaluated. It's simply an efficiency measure.

So, how does one choose one of the 36 results? There are several approaches to this. From those results with the smallest minima, I choose the one with the best-looking plot, i.e., the plot with the closest fit to the data. So, you may ask How can the plot be visibly deviant and still have low residuals? That's because some of the fitmethods ignore some of the points that that fitmethod considers to be outliers.

@jaypantone If the third argument to userinfo is 'NoName', then no function name will be printed.

@smith_alpha No, you haven't expressed it very clearly; in particular, your use of the word "manually" has been confusing. And the Answers provided here by Tom Leslie, Kitonum, and me address the issue of how to sort a list, not how to create that list in the first place. Furthermore, Tom's Answer requires that f initially be a table. Your f is indeed a table in your original posing of this Question, but it won't necessarily be a table when you generate it programmatically.

As I've told you before (in another thread), the most efficient way to create a list in a for loop is to create it as a Vector first. Now sort can be used on a Vector just as well as on a list. So, there's no point in making the list at all---just sort the Vector.

@Kitonum It should be noted that when the sublists have varying lengths, this default sort produces perhaps unexpected results---results that I think many people wouldn't consider properly sorted:

sort([[z,o,o], [c,a,t], [m,a,p,l,e]]);

However, if you view the sublists as being positive integers with their elements being the "digits" (such as the output produced by convert(..., base, ...)), then this default sort is okay.

It should also be noted that you have implicitly converted f to a list and that sort won't work with the original format of f.

@smith_alpha You plan to manually enter ~10^4 sublists into a worksheet rather than, say, reading them from a file or generating them programmatically? Why?

 

@smith_alpha 

If we're only talking about manual input, then that input is necessarily small, and thus efficiency differences are insignificant. If you feel that entering an explicit list is "rather inconvenient" then go ahead and do it the way that you've been doing:

f[1]:= ...;
f[2]:=
...;

etc.

And then immediately after that, convert it to a list with

f:= convert(f, list);

And be aware that before you do the conversion, it isn't a list.

But I'm still surprised that you find it "rather inconvenient". I personally have no problem entering a single list of many hundreds of entries (usually copy-and-pasted from somewhere) across multiple lines. Note that you can use Shift-Enter to continue any input on the next line.

 

Why not just take the solution provided by pdsolve and substitute x= exp(t)? As in

Sol:= pdsolve({sys});
subs(x= exp(t), Sol);

@tomleslie 

Yes, that's another tacit list conversion, and it works fine. However, I want to encourage the OP to avoid making tables in the first place---I doubt that they have any explicit use for a table. This OP in particular has a habit of assigning to sequential indexed entries. Users eventually need to learn that that doesn't create a list or even an array.

@tomleslie 

Certainly this isn't the intended behavior. I believe that it's a failure of the MaplePrimes editor's equation editor.  But a new user can't be expected to know that that editor doesn't work. Even when it does work, the output isn't very good looking:

sum(x[j]*sum(y[i], i= k..n), j= k..n)

The letters are wavy, not crisp. Some parentheses should be added to reduce ambiguity.

Yes, I agree that the use of this should be discouraged.

@acer I've had this problem also. I'll try to recall the details: It was in Windows and in a Document Block. All output, no matter how lengthy, was deferred until the end of command execution. This includes the output of print statements, userinfo statements, and using option trace on procedures. I just assumed that it was one of the numerous hideous features of document mode rather than a bug.

@tomleslie 

I believe (I'm not sure) that when an image appears in a post as a blue square with cut corners and a black capital italic A, that it isn't the user's fault; rather, it's a failure of the MaplePrimes editor's equation editor. Using Firefox (but not Chrome), I can right click on the square and select the option View Image Info. In the box that pops up, one of the fields is Associated Text. The contents of that field are

sum(xj*(sum(yi, i = k .. n)), j = k .. n)

which I liberally interpretted as being intended to be

sum(x[j]*(sum(y[i], i = k .. n)), j = k .. n)

If I've read this correctly, the code beneath your image is

sum(x[j]*sum(y[i], i= k..n), j= k..n).

You ask for help to "solve" this. What does "solve" mean in this context? One usually solves equations or inequalities; the above is simply an expression. Do you mean simplify it, or find a closed form? That can't be done: The expression is too general.

Please upload the data file data1.csv.

@rolfjg I see now that you're working with a fairly old Maple (Maple 12). From the error message that you showed, I suspect that the datasetlabels option was added after Maple 12. I had no way of knowing that since the version where features are added is only very inconsistently mentioned in the help files.

I always would much rather have an actual command than something "interactive". So, try this (with both x and y being lists):

Statistics:-ColumnGraph(zip(`=`, x, y));

I'm 95% sure that this will work in Maple 12. If not, let me know, and I'll come up with something else.

First 466 467 468 469 470 471 472 Last Page 468 of 709