Skip to content

Instantly share code, notes, and snippets.

@mbeltagy
mbeltagy / PoolJumpCalc.ipynb
Last active June 23, 2017 12:10
Jumping from second floor to pool
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mbeltagy
mbeltagy / TupperFormula.ipynb
Created June 7, 2017 10:09
Tupper's_self-referential_formula in Julia
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mbeltagy
mbeltagy / MohRafeaIntroToJuila.ipynb
Created April 25, 2017 19:38
First intro to Mohammed Rafea to Julia for NN
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mbeltagy
mbeltagy / Makefile
Created April 4, 2017 03:01
For the Julia calling C minimal example
CC=gcc
CFLAGS=-c -Wall -fPIC
SOURCES=calc_mean.c
OBJECTS=$(SOURCES:.c=.o)
.c.o:
$(CC) $(CFLAGS) $< -o $@
@mbeltagy
mbeltagy / SandPile.ipynb
Last active January 13, 2017 23:49
Sandpiles from Numberphile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mbeltagy
mbeltagy / kaprekar.jl
Last active April 14, 2017 22:07
Kaprekar's constant from Numberphile
# We work out the Kaprekar's constant
function breakdown(x::Int)
y=[j for j in "$x"]
end
function put_together(y::Vector{Char})
sum(parse(Int,y[i])*10^(i-1) for i=1:length(y))
end
"""
@mbeltagy
mbeltagy / parksim.R
Last active November 28, 2016 17:27
Similar to the parksim in the R probability book, but 10 times faster
parksim <-function(nreps) {
nvals<-rgeom(nreps,0.15)+1
dvals<-ifelse(nvals<=10,11-nvals,nvals-11)
mean(dvals)
}
system.time(parksim(100000000))
@mbeltagy
mbeltagy / int_prob_gen.py
Last active September 23, 2016 22:14
Interactive Integer problem generator for kids
import random
def pm(x):
if x>0:
return "+"
else:
return ""
def int_prob_gen(n):
s=0
@mbeltagy
mbeltagy / int_prob_gen.jl
Last active October 22, 2016 13:16
Interactive Integer problem generator for kids
function int_prob_gen(n)
starting_time=time()
s=0 #successes
pm(x)=x>0? "+":""
for i=1:n
x=rand(-10:10)
y=rand(-10:10)
op=rand(["+","-"])
right_ans="($x)$op($y)"|>parse|>eval
parse_correct=false
@mbeltagy
mbeltagy / GMM_for_clustering.ipynb
Last active September 28, 2020 02:04
Using Gausian Mixtures in the Julia Package https://github.com/davidavdav/GaussianMixtures.jl for clustering.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.