You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
simulacion-permeabilidad/fftma_module/bin/sort5.py

32 lines
486 B
Python

import numpy as np
import random as rd
MAX=100000
def med3(l):
if l[0]<l[1]:
if l[1]<l[2]:
med=l[1]
else:
if l[0]<l[2]:
med=l[2]
else:
med=l[0]
else:
if l[0]<l[2]:
med=l[0]
else:
if l[1]<l[2]:
med=l[2]
else:
med=l[1]
return med
S=0
for i in range(1000000):
l=[float(rd.randint(0,MAX))/MAX,float(rd.randint(0,MAX))/MAX,float(rd.randint(0,MAX))/MAX]
#print l
#L=np.sort(np.array(l))
#print L
S+=np.sort(np.array(l))[1]==med3(l)
print S