Skip to content

Instantly share code, notes, and snippets.

View fmm's full-sized avatar
🏠
Working from home

Filipe Martins fmm

🏠
Working from home
View GitHub Profile
@fmm
fmm / preprocessor_fun.h
Last active August 29, 2015 14:27 — forked from aras-p/preprocessor_fun.h
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@fmm
fmm / em.py
Created December 24, 2015 20:51
import math
import random
# DATA
# 1st: Coin B, {HTTTHHTHTH}, 5H,5T
# 2nd: Coin A, {HHHHTHHHHH}, 9H,1T
# 3rd: Coin A, {HTHHHHHTHH}, 8H,2T
# 4th: Coin B, {HTHTTTHHTT}, 4H,6T
# 5th: Coin A, {THHHTHHHTH}, 7H,3T
a, b = 1, 10
def func(x,y):
'''rosenbrock function'''
return (a - x)**2 + b*(y - x**2)**2
def gradient(x,y):
'''gradient of func'''
dx = 2*(a - x)*(-1) + b*2*(y - x**2)*(-2*x)
dy = 0 + b*2*(y-x**2)*(1)
@fmm
fmm / lms.py
Created January 15, 2016 19:10
sample = [(1,1), (2,2), (3,4), (4,5)] #(x,y)
def h(theta, x):
return theta[0] + theta[1]*x
def j(theta):
total = 0
for (x,y) in sample:
total = total + (h(theta, x) - y)**2
@fmm
fmm / hw1q1.m
Last active January 22, 2016 20:41
%%%%% sigmoid.m %%%%%
function f = sigmoid(z)
f = 1 ./ (1 + exp(-z));
end
%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% likelihood.m %%%%%
function L = likelihood(theta,X,Y)
h = sigmoid(X * theta); % m x 1
L = (Y' * log(h)) + ((1 - Y)' * log(1 - h));
#include <cstdio>
#include <cstdlib>
#include <cmath>
//#define NDEBUG
#include <cassert>
#include <ctime>
#include <cfloat>
#include <climits>
#include <cstring>
@fmm
fmm / gist:05bf23ccf05e4225b3fd0dfd00f3ce6c
Created November 9, 2018 13:02 — forked from soardex/gist:e95cdc230d1ac5b824b3
Install rbenv in CentOS 7
# install build dependencies
sudo yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel
# clone and install rbenv environment
cd ~
git clone git://github.com/sstephenson/rbenv.git .rbenv
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile