Skip to content

Instantly share code, notes, and snippets.

View hichamjanati's full-sized avatar

Hicham Janati hichamjanati

View GitHub Profile
@hichamjanati
hichamjanati / bayesTableGame.py
Created April 18, 2024 09:17
The famous Bayes table game. Computes the probability that Bob wins knowing the score is 5-3 for Alice.
import numpy as np
import time
def estimate_prob_bob_win(n_situations, seed=None, timeout=10):
rng = np.random.default_rng(seed)
bob_wins = 0
n_games = 0
t_start = time.time()
@hichamjanati
hichamjanati / sinkhorn-scipy-sparse.py
Created February 9, 2020 17:34
truncated cost in Sinkhorn
import numpy as np
import warnings
from scipy import sparse
from scipy.stats import norm as gaussian
def make_gaussians(grid, n_hists, loc=None, scale=None, normed=True,
mass=None):
"""Generate random gaussian histograms.
"""
@hichamjanati
hichamjanati / plot_optim.py
Last active November 12, 2021 18:19
Optimization visualization with pyvista
import pyvista as pv
import numpy as np
make_gif = True
# increase n_points for a higher resolution
n_points = 100
xmin, xmax = -1.2, 1.2
bounds = 1.25 * np.array([xmin, xmax, xmin, xmax, 0., 0.])
"""
================================================================
Compute sparse inverse solution with mixed norm: MxNE and irMxNE
================================================================
Runs an (ir)MxNE (L1/L2 [1]_ or L0.5/L2 [2]_ mixed norm) inverse solver.
L0.5/L2 is done with irMxNE which allows for sparser
source estimates with less amplitude bias due to the non-convexity
of the L0.5/L2 mixed norm penalty.