Skip to content

Instantly share code, notes, and snippets.

@silgon
silgon / gist:e6998ed93592ce476d1a
Created June 12, 2015 14:35
IRL with chainMDP
#! /usr/bin/python
"""
Simple example for IRL based on apprenticeship learning
"""
from __future__ import print_function
import numpy as np
def linearMDP(S=5, goal=3):
"""
@silgon
silgon / gist:615e1afe95129682b908
Created June 14, 2015 15:18
TEXI2DVI tilde error
This is an excellent tool when you're compiling latex files. Nevertheless, there's a bug when you insert a tilde as a nbsp. Something that needs to be modified in ''/usr/bin/texi2dvi'', and that's this part of code ''catcode_special=true'' to''catcode_special=false''. After that, a nice example for your latex file is:
texi2dvi --pdf --clean --verbose --batch file.tex
@silgon
silgon / hmm_sampling_fitting.py
Created October 9, 2015 11:47
hmmlearn extended sampling fitting example
"""
this is an extended version of http://hmmlearn.github.io/hmmlearn/auto_examples/plot_hmm_sampling.html#example-plot-hmm-sampling-py
sampling as in the example, then fitting data to another model (with also 4 variables) and then doing some scoring with
the same model and also with a mixture of gaussians
"""
import numpy as np
import matplotlib.pyplot as plt
from hmmlearn import hmm
@silgon
silgon / find_peaks.cpp
Created January 26, 2016 16:05
Eigen Find Peaks C++
Eigen::ArrayXXb findPeaks(Eigen::ArrayXXd &M, unsigned int &footprint_size){
Eigen::ArrayXXb result = Eigen::ArrayXXb::Zero(M.rows(), M.cols());
bool tmp_max;
bool quit_for=false;
for(int i = footprint_size; i<M.rows()-footprint_size; ++i){
for(int j = footprint_size; j<M.cols()-footprint_size; ++j){
tmp_max=true;
for(int ii=i-footprint_size; ii<i+footprint_size;++ii){
for(int jj=j-footprint_size; jj<j+footprint_size;++jj){
if(ii==i && jj==j)
@silgon
silgon / incentive.py
Created September 15, 2016 12:58
Stackoverflow question #39349894
import numpy as np # import library for linear algebra and more utilities
from numpy.random import randint # import random int
# initialize random seed
np.random.seed(4)
houses = ["Gryffindor","Slytherin", "Hufflepuff", "Ravenclaw"]
houses_points = []
for _ in houses:
# houses_points.append(randint(0, 100, randint(60,100)))
@silgon
silgon / .block
Last active April 10, 2017 13:10
Randomly Generated Fill Graph
license: gpl-3.0
@silgon
silgon / carousel.html
Created April 10, 2017 13:54
Example Carousel
@silgon
silgon / .block
Last active April 10, 2017 15:09
Randomly Generated Gradient Fill Graph
license: gpl-3.0
@silgon
silgon / raspberry_pi requisites
Last active July 5, 2017 18:42
HiLink Send Message
sudo usb_modeswitch -v 12d1 -p 1f01 -J
@silgon
silgon / gist:194cfaefe6716b0cea6212215ac36b0d
Created August 9, 2017 19:36
Needed compilation in machine for grpc in my laptop
# in root of grpc project
GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install .