Programación

“Primero resuelve el problema. Entonces, escribe el código.” — John Johnson

viernes, 19 de octubre de 2018

Lo de NumPY

import numpy as np

a = np.array([1, 2, 3])   # Create a rank 1 array
print(type(a))            # Prints "<class 'numpy.ndarray'>"
print(a.shape)            # Prints "(3,)"
print(a[0], a[1], a[2])   # Prints "1 2 3"
a[0] = 5                  # Change an element of the array
print(a)                  # Prints "[5, 2, 3]"

b = np.array([[1,2,3],[4,5,6]])    # Create a rank 2 array
print("forma")
print(b.shape)                     # Prints "(2, 3)"
print(b[0, 0], b[0, 1], b[1, 0])   # Prints "1 2 4"

print("Matriz")
a1 = np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])
print(a1)
# Two ways of accessing the data in the middle row of the array.
# Mixing integer indexing with slices yields an array of lower rank,
# while using only slices yields an array of the same rank as the
# original array:

row_r1 = a1[0, :]   # Rank 1 view of the second row of a
row_r2 = a1[1:2, :]  # Rank 2 view of the second row of a
print("renglon 0")

print(row_r1, row_r1.shape)  # Prints "[5 6 7 8] (4,)"
print("renglon 1")
print(row_r2, row_r2.shape)  # Prints "[[5 6 7 8]] (1, 4)"

# We can make the same distinction when accessing columns of an array:
col_r1 = a1[:, 0]
col_r2 = a1[:, 1:2]
print("columna 0")
print(col_r1, col_r1.shape)  # Prints "[ 2  6 10] (3,)"
print("columna 1")
print(col_r2, col_r2.shape)  # Prints "[[ 2]
                             #          [ 6]
                             #          [10]] (3, 1)"

Instrumentación 5

import numpy as np
m=int(input("Dame numero de muestra, filas") )
l=int(input("Dame numero de lectura, lecturas") )
li=[]
a=[]
lisp=[]
c=1
lit=[]
s=0
for i in range(m):
for j in range(l):
li.append(int(input("Muestra %d, lectura %d" % (i,j))))#esta


lit= [li[l*i : l*(i+1)] for i in range(m)]

a = np.array(lit)
print(a)

print("Maximo ",np.max(a))
print ("Minimo ",np.min(a))

print("cada item de la lista")
for i in range(m):
s=0
for j in range(l):
print("Listas ")
print(lit[i][j])
s=s+lit[i][j]
lit[i].append(s/l)

print()

print(lit)

martes, 16 de octubre de 2018

Tarea para archivos , listas y graficas


https://www.gestiondeoperaciones.net/control-estadistico-de-procesos/ejemplo-de-grafica-de-promedios-y-grafica-de-rangos-en-el-control-estadistico-de-procesos/