import math
import numpy
from sys import argv
def binario(file):
Input = open(file, \'r\')
key = Input.readlines()
Input.close()
aux = \'\'
for l in key:
aux+=l[:-2].strip()
print aux
Output = open(file+\'.binario\', \'w\')
aux = aux.split(\'.\')
key = \'\'
print aux
for a in aux:
if int(a) % 2:
key+= \'1.\'
else:
key+= \'0.\'
key = key[:-1]
print key
monobit(key)
print>>Output, key
Output.close()
#### Monobit function #############################
def monobit(entrada):
entrada = entrada.split(\'.\')
tam = len(entrada)
cont = 0
for e in entrada:
if int(e) == 1:
cont += 1
else:
cont -= 1
form = math.fabs(cont)/math.sqrt(len(entrada))
pValue = math.erfc(form/math.sqrt(2))
print pValue
####################################################
def main():
binario(argv[1])
main()