August 27th, 2003, 02:28 PM

Fit on curve math
Here's a little teaser that I don't remember how to solve from my high school math education!
I have a series of products of different sizes to sell that (unsurprisingly) get cheaper per unit area as the size gets bigger.
However, whilst researching the competition, it seems the current market price per unit area is not a straight linear progression but a curve who's gradient starts off steeply (for smaller areas) but flattens out (as the size reaches the maximum limit).
Can someone give me a clue as to the type of formula to use to calculate these prices?
(The price is also constrained by having to match an initial (competitor's) price for the smallest available size and end, at the maximum size, on a predetermined rate  so, for example: the smallest area available must cost 50 cents per square foot and, for the maximum area available, the price must be 10 cents per square foot, with intermediate area values appearing on the curve previously described).
Also, perhaps you may like to comment on how processorintensive (for PHP) these calculations might be  and whether or not the calculation would best be served using a lookup table  because each user selection may have up to say, fifty products of varying sizes and therefore unit price values that require this price calculation!
Thanks all, in advance
John
Last edited by JohnDI; August 27th, 2003 at 02:33 PM.
August 27th, 2003, 02:41 PM

Least squares regression iirc is a method which attempts to fit a set of points by deternining the minimum possible sum of the squares of the distances of the points on a line from the actual data. There are a whole family of regression techniques, but you have to decide which one to use depending on the nature of your target function  ie you need a different one for a stright line, or a logarithmic curve, or a polynomial (quadratic, cubic etc), or exponential etc.
That's all I remember. I do have a bit of C code, which I used many years ago to manage regressional analysis. I don't think it would mean anything to me if I read it now, but I can dig it out if you like
christo
This is me: http://chris.uk.com
August 27th, 2003, 03:28 PM

Hi Christo
Thanks for the quick reply.
T'was a bit over my head tho' .
Ok, here's the deal. I'm not attempting to exactly match the price curve of my competitors  their attempts to distribute their pricing evenly are all over the shop, anyway
Nevertheless, I want a quick and dirty method of being able distribute my prices evenly along a curve so that the price decrease is relatively steep (gradient) at the outset (smallest areas) and flattens off to a straight line at the maximum area, rather less of a curve than a quarter circle from 270 degrees to 180 degrees (nine o'clock to six o'clock  is that logarithmic?).
I would like to be able to play around by moderating the curve with a constant? until I see the type of variation I like ('like my precise definition ? ) at which point I'll hard code it into the pricing business rules.
Obviously, for speed, I want the formula to be fairly simple. I don't require anything elaborate, just to be able to adjust the curve simply.
Please excuse my imprecision and ignorance of the subject.
Cheers to a fellow Moonraker
John
I grew up in Salisbury!
August 27th, 2003, 03:51 PM

There are a few options available to you here.. thankfully, you're just looking for an approximate function, so we can be quite casual about it.
So yeah, it sounds like you're looking either at a logarithmic funtion log(x), or part of a cubic function ( which could be more useful if you want to extend into the range x<0). So why not just go and fiddle with some curve plotting and see what comes out.. I mean take the competitors' product sizes along x and plot the prices against y, then pick some functions at random to see what fits.. it sounds like you'll need either something in the form
y = log(x)
or
y= ax^3 + bx^2 + cx + d
Where the first curve is a logarithmic function of x and the second is a cubic (polynomial order 3).
christo
ps, what's the moonraker reference?
pps, how d'you manage to escape to Phuket?
This is me: http://chris.uk.com
August 29th, 2003, 12:25 PM

*** This comment has been added since I wrote this post , so...
Please don't bother to reply to these ramblings... I'm getting closer to my solutiuon now, using an exponential formula ... will elucidate later ... thanks, John ***
Thanks for your advice...
"... just looking for an approximate function, so we can be quite casual about it. "
Exactly, 'casual' being the operative word, here.
In fact, I think I must be getting senile  because when I thought about it some more, all I really need to do is to plot an arc of a circle such that I can alter the starting point (starting from between 270 degrees to say 200 degrees) through an arc ending flat at 180 degrees!
Now I'm feeling really dense so perhaps you could spell it out for me Christo?
Here's what I have in an Excel spreadsheet at the mo':
Fixed values:
max_price per cm2: 3.333 Baht for 1,200 cms2
min_price per cm2: 0.667 Baht for 60,000 cms2
Therefore: price_spread = 2.667 Baht
Therefore: size_spread = 58,000 cms2
Cell formula
Price per cm2 = max_price  (area_to_price  min_size) * price_spread / size_spread
This formula at least starts and ends at the right prices (compatable with the max and minimum prices of the competition). However, when I create an Excel graph (that plots prices per cm on the vertical axis against area on the horizontal axis for intervals of every five centimeters e.g. 30 x 40, 35 x 45, 40 x 50 ... ) the curve bulges upwards (making small price variations at the smaller area range) rather than the other way around (large price variations for the smaller areas flattening to little change near the maximum area).
When I fake the area prices across the relevant range, and graph it. I see an arc of a circle of perhaps 30 degrees (although it's suddenly obvious to me that this very much depends on the aspect ratio of the graph axes!).
I'm sure the answer is blindingly obvious, but I'm obviously blind!!!
If you could give me an idea of a formula to plug into Excel then I'm sure I'll be able to translate it into PHP.
However, as I said, the formula needs to be as simple as possible to cut down execution time  so I'm wondering if logarithmic or cubic functions are practical for serverside processing on the Internet requiring as many as fifty calculations (plus database accesses for additional product data)?
Perhaps I'll need a lookup table for the implementation, instead  whadya think?
"... ps, what's the moonraker reference? ..."
Arrr, p'raps you don't 'ave scrumpy cider in Swindon any more. 'Moonrakers' refers to them that's pissed on scrumpy zider tryin' to 'arvest moonlight tha's reflected in village pond, with their grass rakes, ain't it? Hence, moonrakers. Errr, I think!?
"pps, how d'you manage to escape to Phuket?"
Errm, more like 'trapped in poverty' for the last six years! I spent three months and $8,000 in Florida picking up 23 scuba instruction certifications (up to Master Scuba Diver Trainer  which is just short of being able to train Intructors) thinking I could live comfortably for a year or so, in a bungalow on the beach.
Wrong!
However, when I arrived I quickly found out there were numerous student divemasters willing to work for free as dive leaders just to get out on the dive boats, and the dive operators were too cheap and unregulated not to take advantage of this situation! Doh!
Nevertheless, due to my extensive experience of twelve years as an IT documentation and training consultant for the likes of IBM, DEC, Chase Manhattan, etc. I was quickly hired by a dive operator for the vital role of answering the email in the back office (which lasted six? months)! DoubleDoh!
Last edited by JohnDI; August 31st, 2003 at 09:54 AM.