This file contains 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 characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# GradientDescent.py | |
# | |
# Copyright 2015 Overxflow | |
def h0(sample,theta0,theta1): return theta0+sample*theta1 | |
def derivative_0(train_samples,theta0,theta1): return (1.0/len(train_samples))*sum([h0(sample[0],theta0,theta1)-sample[1] for sample in train_samples]) | |
def derivative_1(train_samples,theta0,theta1): return (1.0/len(train_samples))*sum([(h0(sample[0],theta0,theta1)-sample[1])*sample[0] for sample in train_samples]) |
This file contains 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 characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# KNN.py | |
# | |
# Copyright 2015 Overxflow | |
# | |
""" Vector difference """ | |
def v_difference(x,y): return [abs(x[i]-y[i]) for i in xrange(len(x))] |
This file contains 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 characters
/* | |
* linearprey.c | |
* Authors: Jose & Alberto | |
* 2015 | |
*/ | |
#include <windows.h> | |
int main(int argc, char **argv) | |
{ | |
int x = 0; | |
// Posiciones límite // |
This file contains 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 characters
#include <windows.h> | |
#include <time.h> | |
#include <stdlib.h> | |
int main(int argc, char **argv) | |
{ | |
srand(time(NULL)); | |
int x = 0; | |
int uppery = 170; | |
int downy = 600; |
This file contains 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 characters
breed [predators predator] | |
breed [bugs bug] | |
bugs-own [ | |
speed ;; either 1, 2, 3, 4, 5, or 6 | |
] | |
globals [ | |
total-speed-6-caught ;; keeps track of the number of bugs caught with speed of 6 | |
total-speed-5-caught ;; keeps track of the number of bugs caught with speed of 5 | |
total-speed-4-caught ;; keeps track of the number of bugs caught with speed of 4 |
This file contains 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 characters
#!/usr/bin/octave -qf | |
if(nargin!=1) | |
printf("Usage: multinomial.m <data_filename>"); | |
exit(1); | |
end | |
arglist=argv(); | |
datafile=arglist{1}; | |
disp("Loading data..."); |
This file contains 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 characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# PageRank # | |
# Author: Overxfl0w13 # | |
from random import randint | |
def make_ergodic_chain(access_graph,alpha): | |
for i in xrange(len(access_graph)): | |
if reduce(lambda x,y: x+y,access_graph[i])==0: access_graph[i] = [1.0/len(access_graph[i]) for x in access_graph[i]] |
This file contains 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 characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Author: Overxfl0w13 # | |
# KNN para representaciones vectoriales # | |
def p_distance(v1,v2,p=2): | |
""" Calcula las distancias de la familia Lp, http://gyazo.com/b4183c93c58575351334366e3c07370b . | |
Se asumen parámetros correctamente introducidos. | |
This file contains 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 characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Author: Overxfl0w13 # | |
# P Systems # | |
# PI = (O,mu,w1,...,wm,(R1,p1),...,(Rm,pm),i0) # | |
# O -> Alfabeto de objetos (catalizadores, de entrada y de salida) | |
# mu -> estructura de membranas en forma parentizada (estructura de árbol) | |
# w1,...,wm -> Cadenas representación de multiconjuntos asociadas a cada membrana | |
# (R1,p1)...,(Rm,pm) -> Reglas de evolución y relaciones de prioridad |
This file contains 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 characters
# Gauss MLE classifier - 2 classes - # | |
# Author: Overxfl0w13 # | |
function [c] = gauss(X,Y,x) | |
[mX,sigmaX] = matcov(X); | |
[mY,sigmaY] = matcov(Y); | |
pX = columns(X) / (columns(X) + columns(Y)); | |
pY = columns(Y) / (columns(X) + columns(Y)); | |
g1 = x'*((-1/2)*inv(sigmaX))*x+(inv(sigmaX)*mX)'*x+log(pX)-(1/2)*log(det(sigmaX))-(1/2)*mX'*inv(sigmaX)*mX; | |
g2 = x'*((-1/2)*inv(sigmaY))*x+(inv(sigmaY)*mY)'*x+log(pY)-(1/2)*log(det(sigmaY))-(1/2)*mY'*inv(sigmaY)*mY; |