[tahoe-dev] Monte Carlo simulator for emergent reliability

zooko zooko at zooko.com
Fri Sep 7 23:10:37 UTC 2007


Here's a version that uses server unreliability instead of server  
reliability, since floating point numbers are less accurate further  
from 0.  Is that right?  Not sure.  (They are centered around  
2.0...)  Anyway:

#!/usr/bin/env python

import random

def r(k, n, notp, tries=2**20):
     """
     @param k: required shares
     @param n: total shares
     @param notp: server unreliability
     @param tries: number of computrons to sacrifice to the Gods of  
Monte Carlo in order to get an accurate answer
     """
     succs = 0
     i = 0
     while i < tries:
         ups = 0
         for server in xrange(n):
             if random.random() >= notp:
                 ups += 1

         if ups >= k:
             succs += 1

         i += 1

     return float(succs) / tries




More information about the tahoe-dev mailing list