Code in Python:
from numpy import *
from scipy import integrate
from math import sqrt
import pylab as p
import matplotlib.pyplot as mplot
m = 3
K = 3
c = 1
# Funciones
def dx_dt(X, t=0):
x = X[0]
y = X[1]
dx = x*(1 - x/K) - m*x*y/(1+x)
dy = -c*y + m*x*y/(1+x)
return array([dx ,dy])
f = p.figure(figsize=(14, 6))
t = linspace(0,100,500)
X = integrate.odeint( dx_dt, array([1, .5]), t)
p.plot(t, X[:,1], lw=2, color = "green" , label = "Predator")
p.plot(t, X[:,0], lw=2, color = "red" , label = "Prey")
p.grid()
p.legend()
p.xlabel("Time")
p.ylabel("Populations")
f.savefig('RM.pdf')
f.savefig('RM.png')
https://math.la.asu.edu/~halsmith/Rosenzweig.pdf
FREETIME;
pi
jueves, 28 de julio de 2016
miércoles, 14 de diciembre de 2011
Problema bien puesto
Shape from Shading: a well-posed problem? |
- (Existencia) Posee solución.
- (Unicidad) Esta solución es única.
- (Estabilidad) La solución depende continuamente de los datos del problema.
Un problema que satisface estas condiciones es llamado bien puesto.
martes, 13 de diciembre de 2011
Frase 01
…although nature begins with the cause and ends with the
experience we must follow the opposite course, namely
…begin with the experience and by means of it
end with the cause.
Leonardo da Vinci
jueves, 8 de diciembre de 2011
Estructura en VRML (con Python)
Archivo : estructura.py
#Graficador de estructura usando VRML y Python
#20 nov 2011 1:47
#Ejemplo:
#import estructura
#estructura.estructura(2,3,2)
import os
def estructura(n,m,a):
inp=open("plantillaestruc.wrl","r")
outp=open("estructuraVRML.wrl","w")
for linea in inp.readlines():
outp.write(linea)
inp.close()
outp.close()
inp=open("estructuraVRML.wrl","a")
for i in range(1,a+1):
for j in range(n+1):
inp.write("Transform { \nrotation 0 0 1 1.57\ntranslation")
x=m*1.5
y=j*3.0
z=i*3.0
cad=str(x)+" "+str(y)+" "+str(z)
inp.write(" "+cad+"\n")
h=m*3.0
cad=str(h)
inp.write("children [ \nShape {\ngeometry Cylinder {\nradius 0.1\nheight "+cad+"}")
inp.write("\nappearance Appearance {\nmaterial Material {"\
+"diffuseColor 0.1 0.1 0.9 }\n}}]}")
for j in range(m+1):
inp.write("Transform { \ntranslation")
x=j*3.0
y=n*1.5
z=i*3.0
cad=str(x)+" "+str(y)+" "+str(z)
inp.write(" "+cad+"\n")
h=n*3.0
cad=str(h)
inp.write("children [ \nShape {\ngeometry Cylinder {\nradius 0.1\nheight "+cad+"}")
inp.write("\nappearance Appearance {\nmaterial Material {"\
+"diffuseColor 0.1 0.1 0.9 }\n}}]}")
for j in range(n+1):
for i in range(m+1):
inp.write("Transform { \nrotation 1 0 0 1.57\ntranslation")
x=i*3.0
y=j*3.0
z=a*1.5
cad=str(x)+" "+str(y)+" "+str(z)
inp.write(" "+cad+"\n")
h=a*3.0
cad=str(h)
inp.write("children [ \nShape {\ngeometry Cylinder {\nradius 0.1\nheight "+cad+"}")
inp.write("\nappearance Appearance {\nmaterial Material {"\
+"diffuseColor 0.1 0.1 0.9 }\n}}]}")
inp.close()
os.system('./bscontact estructuraVRML.wrl')
Archivo : plantillaestruc.wrl
#VRML V2.0 utf8
#PLANTILLA PARA EL GRAFICADOR
Background {
skyColor [0 0 0, 0 1 0, 1 1 1]
}
#____________________EJES_COORDENADOS_______________
Shape {
geometry IndexedLineSet {
coord Coordinate {
point [5 0 0,-5 0 0,0 5 0,0 -5 0,0 0 5,0 0 -5]}
coordIndex [0,1,-1,2,3,-1,4,5,-1]
color Color {
color [ 1 0 0,0 0 0,0 0 1]}
colorIndex [0,1,2]
colorPerVertex FALSE }
}
Ejemplo:
sábado, 3 de diciembre de 2011
MANIPULACIÓN DE MATRICES(OSEA LISTAS) CON PYTHON
"""MANIPULACIÓN DE MATRICES(OSEA LISTAS) CON PYTHON
Josué Diaz Avalos
Resumen
Aqui algunas funciones para hacer algunas cosas útiles con matrices en Python.
Las Funciones:"""
#1.-
def con1(M1,M2):
c1=len(M1[0])
c2=len(M2[0])
f=len(M1)
M=[]
M=[[0 for j in range(c1+c2)] for i in range(f) ]
for i in range(f):
M[i][0:c1]=M1[i][:]
M[i][c1:c1+c2]=M2[i][:]
return M
#2.-
def con2(M1,M2):
f1=len(M1)
f2=len(M2)
c=len(M1[0])
M=[]
M=[[0 for j in range(c)] for i in range(f1+f2) ]
for i in range(f1):
M[i][:]=M1[i][:]
for i in range(f2):
M[f1+i][:]=M2[i][:]
return M
#3.-
def dia1(M1,M2):
f1=len(M1)
c1=len(M1[0])
f2=len(M2)
c2=len(M2[0])
f=f1+f2
c=c1+c2
a=[]
a=[[0 for j in range(c2)] for i in range(f1) ]
b=[]
b=[[0 for j in range(c1)] for i in range(f2) ]
c=con1(M1,a)
d=con1(b,M2)
M=con2(c,d)
return M
#4.-
def dia2(M1,M2):
f1=len(M1)
c1=len(M1[0])
f2=len(M2)
c2=len(M2[0])
f=f1+f2
c=c1+c2
a=[]
a=[[0 for j in range(c2)] for i in range(f1) ]
b=[]
b=[[0 for j in range(c1)] for i in range(f2) ]
c=con1(a,M1)
d=con1(M2,b)
M=con2(c,d)
return M
#5.-
def diag3(N,n):
Ce=zero(n*len(N),n*len(N[0]))
A=range(0,n*len(N),len(N))
B=range(0,n*len(N[0]),len(N[0]))
for k in range(n):
for i1 in range(len(N)):
for j1 in range(len(N[0])):
Ce[A[k]+i1][B[k]+j1]=N[i1][j1]
return Ce
#6.-
def diag3_0arriba(N,n):
M1=diag3(N,n)
Ce=zero(len(N),n*len(N[0]))
M=con2(Ce,M1)
return M
#7.-
def diag3_0miderecha(N,n):
M1=diag3(N,n)
Ce=zero(n*len(N),len(N[0]))
M=con1(M1,Ce)
return M
#8.-
def diag3_0miizquierda(N,n):
M1=diag3(N,n)
Ce=zero(n*len(N),len(N[0]))
M=con1(Ce,M1)
return M
#9.-
def diag3_0abajo(N,n):
M1=diag3(N,n)
Ce=zero(len(N),n*len(N[0]))
M=con2(M1,Ce)
return M
#10.-
def diag4(N,n):
f=len(N)
c=len(N[0])
Ce=zero(n*f,n*c)
A=range(0,(n-1)*f,f)
B=range(c,n*c,c)
for k in range(n-1):
for i1 in range(len(N)):
for j1 in range(len(N[0])):
Ce[A[k]+i1][B[k]+j1]=N[i1][j1]
return Ce
#11.-
def diag5(N,n):
f=len(N)
c=len(N[0])
Ce=zero(n*f,n*c)
A=range(f,n*f,f)
B=range(0,(n-1)*c,c)
for k in range(n-1):
for i1 in range(len(N)):
for j1 in range(len(N[0])):
Ce[A[k]+i1][B[k]+j1]=N[i1][j1]
return Ce
#12.-
def diag6(N1,N2,n):
A=diag4(N1,n)
B=diag5(N2,n)
C=zero(len(A),len(A[0]))
for i in range(len(B)):
for j in range(len(B[0])):
C[i][j]=A[i][j]+B[i][j]
return C
#13.-
def M1(n):
M=[]
M=[[0 for j in range(n)] for i in range(n) ]
for i in range(n-1):
M[i][i+1]=1
return M
#14.-
def H1(n):
M=[]
M=[[0 for j in range(n+1)] for i in range(2*n) ]
for i in range(n):
M[i][i+1]=1
M[n+i][n-i-1]=1
return M
#15.-
def H2(n):
M=[]
M=[[0 for j in range(2*n)] for i in range(n+1) ]
for i in range(n):
M[i][i]=1
M[n-i][n+i]=1
return M
#16.-
def zero(f,c):
M=[]
M=[[0 for j in range(c)] for i in range(f) ]
return M
#17.-
def iden(n):
M=[]
M=[[0 for j in range(n)] for i in range(n) ]
for i in range(n):
M[i][i]=1
return M
#18.-
def sum(M,N):
S=[]
S=[[M[i][j]+N[i][j] for j in range(len(N[0]))] for i in range(len(M))]
return S
Suscribirse a:
Entradas (Atom)