document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import math
  2. import numpy
  3. from sys import argv
  4. def binario(file):
  5.     Input = open(file, \'r\')
  6.     key = Input.readlines()
  7.     Input.close()
  8.     aux = \'\'
  9.     for l in key:
  10.         aux+=l[:-2].strip()
  11.     print aux
  12.     Output = open(file+\'.binario\', \'w\')
  13.     aux = aux.split(\'.\')
  14.     key = \'\'
  15.     print aux
  16.     for a in aux:
  17.         if int(a) % 2:
  18.             key+= \'1.\'
  19.         else:
  20.             key+= \'0.\'
  21.     key = key[:-1]
  22.     print key
  23.     monobit(key)
  24.     print>>Output, key
  25.     Output.close()
  26. #### Monobit function #############################                                                                                                                                                                
  27. def monobit(entrada):
  28.     entrada = entrada.split(\'.\')
  29.     tam = len(entrada)
  30.     cont = 0
  31.     for e in entrada:
  32.         if int(e) == 1:
  33.             cont += 1
  34.         else:
  35.             cont -= 1
  36.     form = math.fabs(cont)/math.sqrt(len(entrada))
  37.     pValue = math.erfc(form/math.sqrt(2))
  38.     print pValue
  39. ####################################################                                                                                                                                                              
  40.  
  41. def main():
  42.     binario(argv[1])
  43. main()
');