Monte Carlo estimation of best commodity profits

General discussion for players of Oolite.

Moderators: winston, another_commander

Post Reply
al.khwarizmi
Above Average
Above Average
Posts: 23
Joined: Fri Jan 30, 2015 5:34 am

Monte Carlo estimation of best commodity profits

Post by al.khwarizmi »

I have been using and like this Javascript utility:

http://rockthehalo.org.uk/oolite/Oolite ... lator.html

But there's a very important thing it doesn't tell me. It does not tell me the expected (i.e. average) price of a unit of a given commodity, only gives me the spread of possible values in each economy. Those are not the most useful values to have from the standpoint of economic calculation. Moreover, no kind of profit margins are given.

So I decided that I would run the calculation of price for each kind of commodity in each economy 10,000 times to average out the randomness and then format all the data into a report showing in which economies the highest and lowest expected prices for each commodity are to be found, and the expected profit per unit if traded appropriately between those kinds of economies, included here.

Note that these values are for planets, not rock hermits. I haven't actually docked at a rock hermit yet so I don't know a lot about them. I would have to make some somewhat modifications to my code to include them anyway:
Alien Items:
Highest expected price at: Poor Agricultural
Lowest expected price at: Rich Industrial
Expected profit per unit: 42.0

Alloys:
Highest expected price at: Poor Agricultural
Lowest expected price at: Rich Industrial
Expected profit per unit: 2.8

Computers:
Highest expected price at: Poor Agricultural
Lowest expected price at: Rich Industrial
Expected profit per unit: 39.2

Firearms:
Highest expected price at: Poor Agricultural
Lowest expected price at: Rich Industrial
Expected profit per unit: 36.4

Food:
Highest expected price at: Rich Industrial
Lowest expected price at: Poor Agricultural
Expected profit per unit: 5.6

Furs:
Highest expected price at: Rich Industrial
Lowest expected price at: Poor Agricultural
Expected profit per unit: 25.3

Gem-Stones:
Highest expected price at: Rich Industrial
Lowest expected price at: Poor Agricultural
Expected profit per unit: 2.8

Gold:
Highest expected price at: Rich Industrial
Lowest expected price at: Poor Agricultural
Expected profit per unit: 2.8

Liquor/Wines:
Highest expected price at: Rich Industrial
Lowest expected price at: Poor Agricultural
Expected profit per unit: 14.0

Luxuries:
Highest expected price at: Poor Agricultural
Lowest expected price at: Rich Industrial
Expected profit per unit: 22.4

Machinery:
Highest expected price at: Poor Agricultural
Lowest expected price at: Rich Industrial
Expected profit per unit: 16.8

Minerals:
Highest expected price at: Rich Industrial
Lowest expected price at: Poor Agricultural
Expected profit per unit: 2.8

Narcotics:
Highest expected price at: Rich Agricultural
Lowest expected price at: Average Industrial
Expected profit per unit: 46.5

Platinum:
Highest expected price at: Rich Industrial
Lowest expected price at: Poor Agricultural
Expected profit per unit: 5.6

Radioactives:
Highest expected price at: Rich Industrial
Lowest expected price at: Poor Agricultural
Expected profit per unit: 8.4

Slaves:
Highest expected price at: Rich Industrial
Lowest expected price at: Poor Agricultural
Expected profit per unit: 14.0

Textiles:
Highest expected price at: Rich Industrial
Lowest expected price at: Poor Agricultural
Expected profit per unit: 2.8
Enjoy.
User avatar
maik
Wiki Wizard
Wiki Wizard
Posts: 2028
Joined: Wed Mar 10, 2010 12:30 pm
Location: Ljubljana, Slovenia (mainly industrial, feudal, TL12)

Re: Monte Carlo estimation of best commodity profits

Post by maik »

Thanks for that! Interesting to see that illegal items are not even the most profitable. For even better (more obvious) comparability, using the same unit for all items would be good, i.e. giving expected profit for gemstones etc. also per tonne.
al.khwarizmi
Above Average
Above Average
Posts: 23
Joined: Fri Jan 30, 2015 5:34 am

Re: Monte Carlo estimation of best commodity profits

Post by al.khwarizmi »

maik wrote:
Thanks for that! Interesting to see that illegal items are not even the most profitable.
That depends. I haven't taken rock hermits into account. And, though slaves are not quite as profitable as might be expected—I wouldn't deal in them anyway—the other two forms of contraband have a wide margin on them.
maik wrote:
For even better (more obvious) comparability, using the same unit for all items would be good, i.e. giving expected profit for gemstones etc. also per tonne.
Don't the kg and g items all take up no space in the hold?
User avatar
ffutures
---- E L I T E ----
---- E L I T E ----
Posts: 2173
Joined: Wed Dec 04, 2013 12:34 pm
Location: London, UK
Contact:

Re: Monte Carlo estimation of best commodity profits

Post by ffutures »

al.khwarizmi wrote:
maik wrote:
Thanks for that! Interesting to see that illegal items are not even the most profitable.
That depends. I haven't taken rock hermits into account. And, though slaves are not quite as profitable as might be expected—I wouldn't deal in them anyway—the other two forms of contraband have a wide margin on them.
maik wrote:
For even better (more obvious) comparability, using the same unit for all items would be good, i.e. giving expected profit for gemstones etc. also per tonne.
Don't the kg and g items all take up no space in the hold?
They start to use tonnage if you have more than a ton of gold/platinum aboard. This can happen easily enough if you're transporting big cargoes of these materials, and can afford the deposits to load several of them. I had more than 3 tons aboard at the mid-point of my current delivery run, that isn't that unusual.

The oddity is that parcels don't seem to use up any space / weight.
User avatar
Disembodied
Jedi Spam Assassin
Jedi Spam Assassin
Posts: 6885
Joined: Thu Jul 12, 2007 10:54 pm
Location: Carter's Snort

Re: Monte Carlo estimation of best commodity profits

Post by Disembodied »

ffutures wrote:
al.khwarizmi wrote:
Don't the kg and g items all take up no space in the hold?
They start to use tonnage if you have more than a ton of gold/platinum aboard. This can happen easily enough if you're transporting big cargoes of these materials, and can afford the deposits to load several of them. I had more than 3 tons aboard at the mid-point of my current delivery run, that isn't that unusual.

The oddity is that parcels don't seem to use up any space / weight.
Precious metals and (and gems, too, probably) up to 1 tonne are, along with parcels, carried in the ship's safe, which is located in the crew area. They don't take up any space in the cargo hold. When you salvage a quantity of gold/platinum/gems with the fuel scoop, though, the load is directed into the cargo hold and will take up 1T of space until you are able to dock and rearrange the cargo manually.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2453
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: Monte Carlo estimation of best commodity profits

Post by Wildeblood »

al.khwarizmi wrote:
So I decided that I would run the calculation of price for each kind of commodity in each economy 10,000 times to average out the randomness...
Um, forgive me please if I sound dismissive (or pig ignorant), but does the market creation algorithm not produce a normal distribution of price results? Is the result of averaging many runs any different to lowest possible price + highest possible price / 2 :?:
User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6312
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Re: Monte Carlo estimation of best commodity profits

Post by Diziet Sma »

Wildeblood wrote:
but does the market creation algorithm not produce a normal distribution of price results? Is the result of averaging many runs any different to lowest possible price + highest possible price / 2 :?:
Glad to see I'm not the only one this thought occurred to..
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Re: Monte Carlo estimation of best commodity profits

Post by Switeck »

Wildeblood wrote:
al.khwarizmi wrote:
So I decided that I would run the calculation of price for each kind of commodity in each economy 10,000 times to average out the randomness...
Um, forgive me please if I sound dismissive (or pig ignorant), but does the market creation algorithm not produce a normal distribution of price results? Is the result of averaging many runs any different to lowest possible price + highest possible price / 2 :?:
That's certainly not the case for Narcotics, because they flip beyond 102 credits and restart at 0 credits sometimes. I ran across that problem trying to make a modified Cargo Contract OXP.

Granularity of prices (always in intervals of 0.2 or 0.4 credits) can also result in at least slight skewing lower or higher which a simple (lowest + highest) /2 might not catch.

The price difference on many commodities at a single system is often nearly as great or greater than the price difference due to economy changes. It's why trading between Poor Agriculture and Rich Industrial systems is so important -- they maximize the difference and even still it doesn't produce huge and reliable profits going from RI back to PA carrying Furs.
al.khwarizmi
Above Average
Above Average
Posts: 23
Joined: Fri Jan 30, 2015 5:34 am

Re: Monte Carlo estimation of best commodity profits

Post by al.khwarizmi »

Wildeblood wrote:
al.khwarizmi wrote:
So I decided that I would run the calculation of price for each kind of commodity in each economy 10,000 times to average out the randomness...
Um, forgive me please if I sound dismissive (or pig ignorant), but does the market creation algorithm not produce a normal distribution of price results? Is the result of averaging many runs any different to lowest possible price + highest possible price / 2 :?:
I did some histograms of how prices are distributed. They don't appear to be quite normally nor uniformly distributed. Maybe if I were using R proper instead of this thing:

http://www.wessa.net/rwasp_histogram.wasp

...I would get a better sense of how these things are distributed, but the estimates are already done and as it looks now not assuming a symmetric probability distribution was possibly warranted. Intuitively, to me anyway, how prices are calculated using the bitwise AND with a random number suggests that there should be some discontinuities, some lumpiness.
ffutures wrote:
al.khwarizmi wrote:
Don't the kg and g items all take up no space in the hold?
They start to use tonnage if you have more than a ton of gold/platinum aboard.
OK. Are these metric tons?
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: Monte Carlo estimation of best commodity profits

Post by Cody »

ffutures wrote:
They start to use tonnage if you have more than a ton of gold/platinum aboard.
I thought they started to use hold space if you have more than 499kg aboard - but I may be wrong. Yes, metric ton(ne)s (or TC).
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
al.khwarizmi
Above Average
Above Average
Posts: 23
Joined: Fri Jan 30, 2015 5:34 am

Re: Monte Carlo estimation of best commodity profits

Post by al.khwarizmi »

Cody wrote:
ffutures wrote:
They start to use tonnage if you have more than a ton of gold/platinum aboard.
I thought they started to use hold space if you have more than 499kg aboard - but I may be wrong. Yes, metric ton(ne)s (or TC).
In that case, one need only multiply by the appropriate factor. The expected profit moving a metric ton of gemstones from a Poor Agricultural to Rich Industrial economy is 2,800,000 credits.
User avatar
jh145
Dangerous
Dangerous
Posts: 94
Joined: Thu Dec 25, 2014 8:39 pm

Re: Monte Carlo estimation of best commodity profits

Post by jh145 »

al.khwarizmi wrote:
... but the estimates are already done
A couple are off by a tenth. You can get exact figures by looping over the masked MARKET_RND byte for each economy, no Monte Carlo required.
al.khwarizmi
Above Average
Above Average
Posts: 23
Joined: Fri Jan 30, 2015 5:34 am

Re: Monte Carlo estimation of best commodity profits

Post by al.khwarizmi »

jh145 wrote:
al.khwarizmi wrote:
... but the estimates are already done
A couple are off by a tenth. You can get exact figures by looping over the masked MARKET_RND byte for each economy, no Monte Carlo required.
I'll be damned.
Post Reply