Skip to content

Commit 58d1b19

Browse files
committed
BIP-0119: Use the same random seed across simulation runs; fix issue where a poisson was used in place of an exponential
1 parent bef6dc9 commit 58d1b19

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

bip-0119/simulation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def get_rate(phase):
2424
return 1.25**(phase)*TXNS_PER_SEC
2525

2626
def normal():
27+
np.random.seed(0)
2728
print("Max Txns Per Sec %f"%TXNS_PER_SEC)
2829
backlog = 0
2930
results_unconfirmed = [0]*SAMPLES
@@ -43,6 +44,7 @@ def normal():
4344
results_unconfirmed[i] = backlog/AVG_TX
4445
return results_unconfirmed, np.cumsum(total_time)/(60*60*24.0)
4546
def compressed(rate_multiplier = 1):
47+
np.random.seed(0)
4648
print("Max Txns Per Sec %f"%TXNS_PER_SEC)
4749
backlog = 0
4850
secondary_backlog = 0
@@ -54,7 +56,7 @@ def compressed(rate_multiplier = 1):
5456
total_time = [0]*(SAMPLES)
5557
for phase in range(PHASES):
5658
for i in range(PHASE_LENGTH*phase, PHASE_LENGTH*(1+phase)):
57-
block_time = np.random.poisson(AVG_INTERVAL)
59+
block_time = np.random.exponential(AVG_INTERVAL)
5860
total_time[i] = block_time
5961
txns = np.random.poisson(rate_multiplier*get_rate(phase)*block_time)
6062
postponed = txns * COMPRESSABLE

0 commit comments

Comments
 (0)