title: Monte Carlo Simulations Python
body: <p>I am using Monte Carlo simulations to simulate a preservation system.
  I have devices in my simulation with certain fail rate. Lets say the fail rate is 1/100000 meaning 1 out of 100000 devices fail each year. If the device fail I pay for the replacement. But I don't get how to catch the device failure randomly in the simulation. As I understand I need to use probability distribution to simulate this behavior. But I do not get how to do it. </p>
  
  <p>Functions in random package seem to provide random number in a particular range which I do not have. Also I do not know what sort of distribution this is.  </p>
  
  <p>I hope the question makes sense to people. Any help will be appreciated.</p>
  
  <p>Update on this:</p>
  
  <p>I did this </p>
  
  <pre><code>    #/usr/bin/python
      import random 
  
      def main():
          count =0
          #fail rate is 1% of 100000, I need to do this probabilistically
          for _ in range(1,100000):
              x=random.random()
              if x &lt;= 1.0/100000:
                  count += 1
  
                  print "x = "+str(x)+" fail device"
          print "device failed "+str(count)+"  times"
  
      if __name__ == '__main__':
          main()
  </code></pre>
  
  <p>and I get output like</p>
  
  <pre><code>        x = 0.000743343826396 fail device
          device failed 1  times
          [Finished in 0.0s]
  </code></pre>
  
  <p>Thanks to timgeb for the help! However, I wonder if this behavior is the same as considering a fail rate of 1/100000?</p>