[SciPy-user] optimization question

zunzun@zunzu... zunzun@zunzu...
Wed Jul 4 02:19:52 CDT 2007


On Wed, Jul 04, 2007 at 08:51:55AM +0200, Volker Lorrmann wrote:
> 
> What do you mean by a costfunction?

If I want to minimize the sum of squared errors for some
data as inputs to an equation, my "cost function" will
calculate the sum of square derrors.

If I want to minimize the inverse sum of absolute errors
for the same data and equation, my "cost function" would
calculate that instead.

The cost function calculates whatever it is your minimizer
will be minimizing.


> Maybe you can give a short example, if its not to much work.

Some badly written pseudocode to illustrate;

First define a cost function, this returns a value
to be minimized - here the sum of squared error.

function SSQ_cost_func(data, equation_function)
{
     calculate and return the sum of squared error
}

now pass this to the minimizer:

minimize(SSQ_cost_func, data, equation_function)


BTW, don't people on this mailing list ever sleep?
It's 2:00 AM here in Birmingham, Alabama.

     James Phillips
     http://zunzun.com



More information about the SciPy-user mailing list