Skip to content

Instantly share code, notes, and snippets.

@matthieubulte
matthieubulte / main.jl
Created March 26, 2021 22:03
Compiling sparse matrix multiplication
using LinearAlgebra
using BenchmarkTools
using SparseArrays
# To exploit the sparsity of the matrix as much as possible, pre-compile the multiplication operation
# to skip the matrix entries look-up. Since the matrix is sparse this might generate only a few operations
# which are all inlined.
# Note that this only works with small matrices since otherwise the size of the function will just be to
# large.
# Note that this could also be avoided, but this is another topic.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matthieubulte
matthieubulte / Estimating a covariance.ipynb
Last active June 4, 2019 21:29
Automatic MLE of a covariance matrix via Cholesky factorization
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matthieubulte
matthieubulte / RandomRDD with custom PRNG.ipynb
Last active June 1, 2019 18:08
RandomRDD with custom PRNG.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matthieubulte
matthieubulte / Removing collinearity via SVD.ipynb
Last active May 26, 2019 15:57
Removing collinearity via SVD (maybe?)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matthieubulte
matthieubulte / np_par.py
Last active February 2, 2019 04:07
Numpy parallelism
import multiprocessing as mp
import numpy as np
def multiprocessing(f, data, nproc):
chunks = np.array_split(data, nproc)
with mp.Pool(nproc) as ex:
res = ex.map(f, chunks)
return np.concatenate(list(res))
def dosomething(xs):
@matthieubulte
matthieubulte / Tutorial.ipynb
Last active June 2, 2019 18:18
MLSSMC Tutorial
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def smc(M, steps, prior, potential, proposal_kernel, correction_steps=1, ess_ratio=2):
"""
smc(M, steps, prior, potential, proposal_kernel, correction_steps=1, ess_ratio=2)
Creates a particle approximation of a probability distribution using the Sequential
Monte Carlo (SMC) algorithm with Markov Chain Monte Carlo (MCMC) correction steps using
the Metropolis-Hastings algorithm.
Parameters