Skip to content

Instantly share code, notes, and snippets.

View angeris's full-sized avatar
😄

guille angeris

😄
View GitHub Profile
@angeris
angeris / estimate_crappy_pi.py
Last active August 31, 2016 17:04
Runs different, crappy ways of estimating Pi
from numpy import *
N, L = 1e8, 10
print("Here's your crappy estimation of pi: {}".format((sum(exp(-(random.rand(N)*2*L-L)**2))*2*L/N)**2))
@angeris
angeris / Matrix.java
Last active August 31, 2016 17:03
A simple, naive Matrix class with QR factorization, back-substitution, and least squares in Java for use in Hackerrank's easier Statistics/Machine Learning problems
/*
* I threw together this set of classes to work on Hackerrank's stuff at a fairly low level. Of
* course, you are provided with several libraries to do this for you, such as Weka, which makes
* life quite a bit easier than setting up your own feature matrix. But for those who want to
* have the simple stuff such as naive QR using Gram-Schmidt, back-substitution, and school-book
* matrix multiplication, this will work. Even for fairly large datasets within Hackerrank
* the performance is fast enough to give a very wide margin of extra time. Enjoy!
*
* Guille (@Guillean)
*/