Advertisement
Guest User

Untitled

a guest
Sep 15th, 2015
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2. import math
  3. import numpy as np
  4. from collections import deque
  5. import matplotlib.pyplot as plt
  6. from matplotlib import mlab
  7.  
  8. def digits2number(digits):
  9.     return int(''.join([str(d) for d in digits]))
  10.  
  11. X = []
  12. for i in range (10000):
  13.     unic_digits = deque(range(0, 10))
  14.     num_len = 1 + math.floor(math.log(random.randint(1, 10000), 10))
  15.     random.shuffle(unic_digits)
  16.     if (unic_digits[0] == 0):
  17.         unic_digits.rotate(1)
  18.     X.append(digits2number(list(unic_digits)[:int(num_len)]))
  19.  
  20.  
  21. plt.hist(X, 100, histtype='step', cumulative=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement