Created
February 14, 2013 15:10
Revisions
-
nightkrowl created this gist
Feb 14, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ BEGIN { count = 0; sumall = 0; } { sumall = sumall + $1; count = count + 1; } END { Resfinal = sumall/count; print Resfinall; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ set term png set output 'algo.png' set xrange [0:9] #rangos set yrange [0.1:0.9] set zrange [0.1:0.9] set xlabel "Potencias" set ylabel "Frecuencia" set zlabel "Exitos" set pm3d implicit at s splot 'resultados.txt' This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ import sys, math, random def Words(chain, freczero): #function to create the words word = [] contzero = 0 contone = 0 limite0 = int (chain * freczero) limite1 = chain - limite0 for i in range(chain): nums = random.randint (0,1) if (nums == 0): contzero = contzero + 1 if (contzero > limite0): word.append = (1) else: word.append = (0) else: contone = contone + 1 if (contone >= limite1): word.append(0) else: word.append(1) return word def Transmision(message, probzero, probone): # function to send the word and create a list with the message msg = [] for i in message: x = random() if i == 0: if x < probzero: msg.append = (0) else: msg.append = (1) else: if x < probone: msg.append = (1) else: msg.append = (0) if message == msg: return 1 else: return 0 def main(): chain = int(argv[1]) # lenght of the word probzero = float(argv[2]) # frequency to transmit a zero probone = float(argv[3]) # frequency to transmit a one freczero = float(argv[4]) iteration = int(argv[5]) wins = 0 for i in range(iteration): message = Words(chain, freczer) restrans = Transmision(message, probzero, probone) if (restrans == 1): wins = wins + 1 goods = float(wins)/float(iteration) print goods This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ #!/bin/bash # Las siguientes funciones son para checar # si existe el documento, para que no haya # problemas. dat=resultados.txt if [ -e $dat ]; then rm resultados.txt fi dat2=awk.txt if [ -e $dat2 ]; then rm awk.txt fi touch resultados.txt for chain in 20 15 10 5; do for probzero in 0.5 0.3 0.7 0.9; do for probone in 0.6 0.8 0.3 0.4; do for freczero in 0.8 0.9 0.6 0.3; do touch awk.txt for iteration in 1 2 3 6; do goods=`python canal.py $chain $probzero $probone $freczero $iteration` echo $goods >> awk.txt done resgoods=`awk -f Obed.awk awk.txt` #instruccion para tomar todas las impresion del archivo awk echo $chain $probzero $probone $freczero $resgoods >> resultados.txt #pasamos los datos rm awk.txt done done done done gnuplot algo.plot #creamos el plot eog algo.png