Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |
 User Name: Password: Remember me

New Free Tools on Dev Shed!
We're Excited to announce that Dev Shed now has 70 free tools on the site. To learn more, click here!

 Add This Thread To: Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb
 « Previous Thread | Next Thread » Thread Tools Search this Thread Rate Thread Display Modes
 Dev Shed Forums Sponsor:
#1
August 27th, 2003, 03:28 PM
 JohnDI
Junior Member

Join Date: Aug 2003
Location: Phuket, Thailand
Posts: 3
Time spent in forums: < 1 sec
Reputation Power: 0
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 processor-intensive (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 03:33 PM.

#2
August 27th, 2003, 03:41 PM
 christo
Introspective

Join Date: Nov 2001
Location: London, UK
Posts: 3,317
Time spent in forums: 3 Days 5 h 42 m 47 sec
Reputation Power: 110
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

#3
August 27th, 2003, 04:28 PM
 JohnDI
Junior Member

Join Date: Aug 2003
Location: Phuket, Thailand
Posts: 3
Time spent in forums: < 1 sec
Reputation Power: 0

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!

#4
August 27th, 2003, 04:51 PM
 christo
Introspective

Join Date: Nov 2001
Location: London, UK
Posts: 3,317
Time spent in forums: 3 Days 5 h 42 m 47 sec
Reputation Power: 110
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?

#5
August 29th, 2003, 01:25 PM
 JohnDI
Junior Member

Join Date: Aug 2003
Location: Phuket, Thailand
Posts: 3
Time spent in forums: < 1 sec
Reputation Power: 0

*** 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 server-side 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)! Double-Doh!

Last edited by JohnDI : August 31st, 2003 at 10:54 AM.

 Viewing: Dev Shed Forums > Programming Languages - More > Software Design > Fit on curve math

## Developer Shed Advertisers and Affiliates

 Thread Tools Search this Thread Search this Thread: Advanced Search Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off
 View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox Forum Jump Please select one User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home -------------------- Programming Languages    PHP Development        PHP FAQs and Stickies    Perl Programming        Perl FAQs and Stickies    C Programming        C Programming FAQs and Stickies    Java Help        Java FAQs    Python Programming        Python Programming FAQs    Ruby Programming        Ruby Programming FAQs    Game Development        Game Development FAQs Programming Languages - More    ASP Programming        ASP Programming FAQs    .Net Development        .Net Development FAQs    Visual Basic Programming        Visual Basic Programming FAQs    Software Design        Software Design FAQs    ColdFusion Development        ColdFusion Development FAQs    Delphi Programming        Delphi Programming FAQs    Regex Programming        Regex Programming FAQs    XML Programming        XML Programming FAQs    Other Programming Languages        Other Programming Languages FAQs Web Design    HTML Programming        HTML Programming FAQs    JavaScript Development        JavaScript Development FAQs    CSS Help        CSS Help FAQs    Flash Help        Flash Help FAQs    Photoshop Help        Photoshop Help FAQs    Web Design Help        Web Design Help FAQs    Website Critiques        Website Critiques FAQs    Search Engine Optimization        Search Engine Optimization FAQs Mobile Programming    Mobile Programming        Mobile Programming FAQs    iPhone SDK Development        iPhone SDK Development FAQs    Android Development        Android Development FAQs    BlackBerry Development        BlackBerry Development FAQs Web Site Management    Business Help        Business Help FAQs    Development Software        Development Software FAQs    Scripts        Scripts FAQs Databases    Database Management        Database Management FAQs    DB2 Development        DB2 Development FAQs    MySQL Help        MySQL Help FAQs    PostgreSQL Help        PostgreSQL Help FAQs    Firebird SQL Development        Firebird SQL Development FAQs    MS SQL Development        MS SQL Development FAQs    Oracle Development        Oracle Development FAQs    LDAP Programming        LDAP Programming FAQs System Administration    Mail Server Help        Mail Server Help FAQs    Apache Development        Apache Development FAQs    Security and Cryptography        Security and Cryptography FAQs    Antivirus Protection        Antivirus Protection FAQs    DNS        DNS FAQs    IIS        IIS FAQs    Networking Help        Networking Help FAQs    FTP Help        FTP Help FAQs Operating Systems    BSD Help        BSD Help FAQs    Linux Help        Linux Help FAQs    UNIX Help        UNIX Help FAQs    Windows Help        Windows Help FAQs    Mac Help        Mac Help FAQs Web Hosting    Web Hosting        Web Hosting FAQs    Free Web Hosting        Free Web Hosting FAQs    Web Hosting Requests        Web Hosting Requests FAQs    Web Hosting Offers        Web Hosting Offers FAQs Computer Hardware    Computer Hardware    CPUs        CPUs FAQs    Cooling        Cooling FAQs    Embedded Programming        Embedded Programming FAQs    Motherboards        Motherboards FAQs    Multimedia Hardware        Multimedia Hardware FAQs Other    Dev Shed Lounge        Dev Shed Lounge FAQs    Development Articles        Development Articles FAQs    Beginner Programming        Beginner Programming FAQs    Hire A Programmer        Hire A Programmer FAQs    Project Help Wanted        Project Help Wanted FAQs Latest News Updated Hourly    Technology News    Business News    Science News Forum Information    Forum Rules/Guidelines        Forum Rules/Guidelines FAQs    Forum Announcements        Forum Announcements FAQs    Dev Shed Gaming Center        Go to the Dev Shed Battle Arena        Go to the Dev Shed Arcade Games        Go to the Legend of the Green Dragon    Suggestions & Feedback        Suggestions & Feedback FAQs

 Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap