Estimation based on ratios

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jabbaonthedais
Forum Contributor
Posts: 127
Joined: Wed Aug 18, 2004 12:08 pm

Estimation based on ratios

Post by jabbaonthedais »

I am developing a browser-based game in PHP and I am trying to find the best way to do something. I wondered if some fresh eyes could help me out.

Users will have a store and I need to calculate sales they get based on an average ratio. Let's say 1 out of 35 customers typically make a purchase. If they get 350 customers a day, they would average 10 sales a day. But thats too exact, and its not real. If you take that ratio to real life, each customer has a 1:35 chance of making a sale, and therefore you could have 2 or more in a row. I want to have a bit more realism but something that makes sense using that average ratio. I could do a loop for each customer, but I need code that can scale with potentially thousands of users and thousands of virtual customers.

Could I make 35 (or whatever my 1: ratio is) a weight for picking a random number, that would much more likely be 30-40 rather than 100?

If I can explain something better please let me know. Thanks in advance for your help! :)
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Estimation based on ratios

Post by McInfo »

Where do your numbers come from? I'm referring to "1 purchase per 35 customers" and "350 customers per day". Will those be based on data gathered during the game or are they predetermined at some point?

I did some research and discovered that a graph of randomly-generated sales volumes based on your criteria looks a little bit like a cosine curve with a peak near the average sales per day. Maybe there is a mathematical expression you could plug a random number into to get a sales-per-day figure where the likelihood of getting a particular figure is weighted as you described.
jabbaonthedais
Forum Contributor
Posts: 127
Joined: Wed Aug 18, 2004 12:08 pm

Re: Estimation based on ratios

Post by jabbaonthedais »

The number of customers will be based on different action the user takes (promotion and advertisements for store, etc.) and the ratio will depend on items the user keeps in stock, so they will fluctuate.

I think you're right about there having to be an expression to solve this. I just need to find one or figure one out. :P

Thanks!
Post Reply