If the block changes every 30 seconds on average, and you find a share every 30 seconds on average, and someone else finds a share every 5 seconds, how do you have the same chances?
You cannot precalculate when an event may happen like this, that would violate you having a constant chance of finding a hash, and would make it dependent on the past. If I find a share now, I have the exact same chance of finding it one share later, since you find shares (approx) instantly. Or let me put it this way: assuming you have been unlucky, and got e.g. 0 shares in the time were on average supposed to get two: this does not make it any more likely that you will now find shares in the next timespan. Since you are constantly looking for shares and with the same probability at each point in time, the Poisson process continues even over block changes, so you can't just reset the time.
I explained this in the old thread. If you have an event that has a constant chance of happening in time (e.g. finding a hash, nuclear decay in atoms, ...), the amount of times the event occurs on average in a given timespan (here: between two blocks) is given by the Poisson distribution.
Here is the probability (y axis) that you find N shares (x-axis) between the two blocks if your hashrate is equal to the block find time.
Another analogy. You are gambling with slot machines that are free to use. Every time the block changes you have to change slot machines (but you can do so instantly, we are not simulating latency). By your argument, someone who can pull the lever five times as fast, would get more than five times what you got. Why should that be the case?
I suggest you read up a bit on
the Poisson processes, I don't think you understand it quite correctly at the moment. Additionally, I'm confident I know what I'm talking about, I study physics. I'm also by no means a fast miner, I have a measly 1 MH/s.
You'll completely whiff on any given block just as often as you get one share.. meanwhile the other guy gets 6 in. If he has a little bad luck, he gets 5. You have a little bad luck? you get 0. But, it all evens out right? A little bad luck this time, a little good luck next time. Of course every time you have a little good luck, you don't get 2, you'll still get 1. He'll get 7
You each have a good block and a bad block. You have 1 share. He has 12.
1/12 is not the same ratio as the ratio as 1/6.
He might get 7, but that's only 17% more than he should have gotten. When you get 2, that's a 100% more than what you should have gotten. Here's the picture accompanying the above, for a miner that has 6x the hashrate of the share-rate-equal-to-block-rate miner:
Now on to your simulation: You are using the wrong distribution. If you don't know why, read my post again from the top, read the wiki page or watch the video I linked above.
The pobability distribution of the times between finding shares (again, this is a poisson process) is simply e^(-t/T), where T is the average time between shares. Which has exactly the property that you can just restart it at all points without changing anything.
Here is the correct version of your code:
import numpy.random as rnd
class worker():
sharetime = None #time the next share is found
def __init__(self,avgsharetime):
self.avgsharetime = avgsharetime
self.hashrate = 60/avgsharetime
self.shares = 0
self.generatesharetime(0.0)
def generatesharetime(self, currenttime):
self.sharetime = currenttime + rnd.exponential(scale=self.avgsharetime)
class pool():
blocktime = None #time the next block is found
def __init__(self,avgblocktime):
self.avgblocktime = avgblocktime
self.generateblocktime(0.0)
def generateblocktime(self,currenttime):
self.blocktime = currenttime + rnd.exponential(scale=self.avgblocktime)
pool1 = pool(2)
worker1 = worker(12)
worker2 = worker(1)
duration = 1000.
t=0.
while t if pool1.blocktime t=pool1.blocktime
print "new block t=",t
worker1.generatesharetime(t) #if you disable these, nothing changes in the outcome
worker2.generatesharetime(t) #
pool1.generateblocktime(t)
elif worker1.sharetime t=worker1.sharetime
print "worker 1 found a share t=",t
worker1.shares+=1
worker1.generatesharetime(t)
elif worker2.sharetime t=worker2.sharetime
print "worker 2 found a share t=",t
worker2.shares+=1
worker2.generatesharetime(t)
else:
print "this is hugely improbable"
print worker1.shares
print worker2.shares
print "Worker 1 has: " + str((float(worker1.hashrate) / float(worker2.hashrate + worker1.hashrate)) * 100) + ' percent of the hash power'
print "But worker 1 has: " + str((float(worker1.shares) / float(worker2.shares + worker1.shares)) * 100) + ' percent of the profit'
#print "Over sample size of " + str(samplesize)
print "When worker1's average share-find-speed was: " + str((float(pool1.avgblocktime) / float(worker1.avgsharetime))) + "x the block time"
Example Output:
blocks and shares over timeWorker 1 has: 7.69230769231 percent of the hash power
But worker 1 has: 8.26645264848 percent of the profit
When worker1's average share-find-speed was: 0.166666666667x the block time