I Distribute gold among items depending on demand

  • I
  • Thread starter Thread starter Addez123
  • Start date Start date
  • Tags Tags
    Gold
Addez123
Messages
199
Reaction score
21
TL;DR Summary
I have a table of items.
Each item has a
- demand, representing how many items has been sold
- desiredPrice: Given defaultDemand, the price should equal desiredPrice

There's a pot of gold that should be distributed among all items.
Items with high demand should receive LESS gold, and items with little demand should receive MORE gold.

The total gold in the pot equals the sum of all desiredPrice's among the items.

How do I calculate the price from demand?
How do I calculate defaultDemand?
This turned out to be more difficult than I thought!

Right now my calculations for the price for each item:
price = (1 - demand/totalDemand) * goldToDistribute

It doesn't work, example case:
goldToDistribute = 10

a.demand = 10
b.demand = 90
c.demand = 100
totalDemand = 200
a.price = (1 - 10/200)* 10 = 9.5
b.price = (1 - 90/200)* 10 = 5.5

already here we can see we've distributed 15gold when we only had 10 gold to distribute.
What would be a better function for price?

Basically what I'm looking for is a solution to
price = f(demand, totalDemand, goldToDistribute)
 
Mathematics news on Phys.org
Addez123 said:
Summary: I have a table of items.
Each item has a
- demand, representing how many items has been sold
- desiredPrice: Given defaultDemand, the price should equal desiredPrice
In your example, you show only the demand and a price, but not the desired price.
Addez123 said:
There's a pot of gold that should be distributed among all items.
Items with high demand should receive LESS gold, and items with little demand should receive MORE gold.

The total gold in the pot equals the sum of all desiredPrice's among the items.

How do I calculate the price from demand?
How do I calculate defaultDemand?

This turned out to be more difficult than I thought!

Right now my calculations for the price for each item:
price = (1 - demand/totalDemand) * goldToDistribute

It doesn't work, example case:
goldToDistribute = 10

a.demand = 10
b.demand = 90
c.demand = 100
totalDemand = 200
a.price = (1 - 10/200)* 10 = 9.5
b.price = (1 - 90/200)* 10 = 5.5

already here we can see we've distributed 15gold when we only had 10 gold to distribute.
What would be a better function for price?

Basically what I'm looking for is a solution to
price = f(demand, totalDemand, goldToDistribute)
What is the DesiredPrice? What is DefaultDemand? Is your task to come up with a formula for price?

It seems like there is a lot of information that is missing. If this is a textbook problem, what is the exact problem statement?
 
  • Like
Likes FactChecker
Mark44 said:
In your example, you show only the demand and a price, but not the desired price.

What is the DesiredPrice? What is DefaultDemand? Is your task to come up with a formula for price?

It seems like there is a lot of information that is missing. If this is a textbook problem, what is the exact problem statement?
I'm also interested in this question... for non homework reasoning.

I believe the desired price he's looking for is not a number, rather a percentage. The desired price is 100% of what it demands at the default demand. He then gives demand for each item, but at 200%. Indicating its twice the amount of available currency, which is 10.

Should not you cancel the 200% into 100% by halfing the values of...x(??) Then split the 10 gold to the three items based on what percentage of the 100% each is.
 
Mark44 said:
What is the DesiredPrice? What is DefaultDemand? Is your task to come up with a formula for price?
So it's a coding problem for a game I do on my spare time.

desiredPrice could be any number. It's irrelevant to the equation but it's calculated based on the time it takes to obtain said item.

Default demand is what I need to calculate.
Basically, if I set the demand of every item to defaultDemand, then the price should end up being our desiredPrice.

Mark44 said:
Is your task to come up with a formula for price?
Yes. And after that a formula to calculate defaultDemand based on the price formula.
 
zeanah said:
Should not you cancel the 200% into 100% by halfing the values of...x(??) Then split the 10 gold to the three items based on what percentage of the 100% each is.

Changing the formula to
price = (1 - demand/totalDemand) * goldToDistribute * 100/totalDemand
works for this example but doesn't work if c = 200
 
Basically you can calculate the price through this process:a.demand = 10
b.demand = 90
c.demand = 100
totalDemand = 200

a.stake = 1 - a.demand/totalDemand
b.stake = ...

totalStake = a.stake + b.stake + c.stake

a.price = a.stake/totalStake * goldToDistribute

But if I use this approach I have no way of calculating defaultDemand.
For example, what should a.demand be in order to get a.price = 6?
 
Addez123 said:
Basically you can calculate the price through this process:a.demand = 10
b.demand = 90
c.demand = 100
totalDemand = 200

a.stake = 1 - a.demand/totalDemand
b.stake = ...

totalStake = a.stake + b.stake + c.stake

a.price = a.stake/totalStake * goldToDistribute

But if I use this approach I have no way of calculating defaultDemand.
For example, what should a.demand be in order to get a.price = 6?
It should be 150% of whatever b.demand + c.demand equals right? Considering you have 10, want to allocate 6 of that to a, leaving the other two some combination that equals 4. 6 is 150% of 4, do that is the answer? I'm not to great at math either tbh, but I have a very similar problem like this i am trying to code as it relates to a game also. It had to do with classifying different tasks based in their averaged gold/second return and comparing.. Yada yada
 

Similar threads

Back
Top