in reply to Average Price Algorithm

Is it just me, or is there the distinct smell of homework in this node ??

There's no indication of any efforts on behalf of the poster thus far - apart from a calculation of the average price - a task which is, to say the least, trivial in the extreme.

A user level that continues to overstate my experience :-))

Replies are listed 'Best First'.
Re^2: Average Price Algorithm
by tilly (Archbishop) on Jan 29, 2009 at 02:16 UTC
    The problem as given is not well-defined, which is a pretty clear sign that it is not homework. It is not well-defined because it is unclear what the metric is for the "best" fit. Are we trying to minimize the maximum error? Are we trying to minimize the average error? Are we trying to minimize the sum of the squares of the errors? All three would fit the problem description, and all three can lead to different optimal answers.

    The fact that the problem looks NP complete is just icing on the "probably not homework" cake.

Re^2: Average Price Algorithm
by Anonymous Monk on Jan 30, 2009 at 01:10 UTC
    Sounds more like he's trying to hand out shares of Apple stock as awards. (I hope they're not back-dating them again) That's the only good reason I can think of to need to track the original prices. However, use of the term "commodity" is completely wrong as that denotes an asset that has no distinguishing characteristics from unit to unit. If it were truly a commodity, the answer would be "charge everyone the average price and it doesn't matter which units they get".