The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Black box optimization
Replies: 2   Last Post: May 3, 2012 10:24 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
McHale, Paul

Posts: 60
Registered: 5/29/11
Black box optimization
Posted: Apr 28, 2012 5:32 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Is there any black box optimization of user defined non-polynomial functions in Mathematica? I.e.

I want to minimize fm[x] between 0.010 and 0.060. The goal is to fit the data with mx+b. This requires two points. The first point in the data has to be zero or first element shown below. The other single point must allow a fit with minimum error between the original data points and the new data points generated from an mx+b approximation.

(* Use mMinFit to select Y value for selected point *)
mMinFit=Fit[Select[InData, #[[1]] > 0.01&],{1,x},x];
(* Generate fit between new fit between first point and new test point *)
mFit=Fit[{First@InData,{mPt,mMinFit /. x->mPt}},{1,x},x];
(* subtract real data from points generated by new curve *)
mError=Total@Table[Abs@(m[[2]]-mFit /. x ->m[[1]]),{m,InData}]

Calling fm[0.01] calculates the fit using {{0.`,0.3457378`},{0.01,InterpValue} as the two points mx+b must pass through. It then returns the Abs[] of
the difference between the original points (InData) and the interpolated points based on original x values. This is intended to be the error function. Minimizing fm[x] should give the best possible choice of x to calibrate with.

I can always fall back to:

First@Sort[m,#1[[2]] < #2[[2]]&]

Out:= {0.04474,2.13522}

Here is a decent graph of the issue:

ListPlot[Table[fm[i], {i, 0.010, 0.060, 0.001}], Joined -> True]

I thought I found a better way in Mathematica before...

Paul McHale | Electrical Engineer, Energetics Systems | Excelitas Technologies Corp.

Phone: +1 937.865.3004 | Fax: +1 937.865.5170 | Mobile: +1 937.371.2828
1100 Vanguard Blvd, Miamisburg, Ohio 45342-0312 USA

Please consider the environment before printing this e-mail.
This email message and any attachments are confidential and proprietary to Excelitas Technologies Corp. If you are not the intended recipient of this message, please inform the sender by replying to this email or sending a message to the sender and destroy the message and any attachments.
Thank you

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.