Skip to content

Instantly share code, notes, and snippets.

View tupui's full-sized avatar
⚙️
Building Tansu

Pamphile Roy tupui

⚙️
Building Tansu
View GitHub Profile
@tupui
tupui / perturb_discrepancy.py
Created January 28, 2019 22:34
Compute discrepancy for an elementary perturbation of a LHS - For statsmodels
from functools import lru_cache
import numpy as np
import copy
import openturns as ot
from statsmodels.tools import sequences
dim = 2
n_samples = 20
doe_init = np.array(ot.SobolSequence(dim).generate(n_samples))
disc_init = sequences.discrepancy(doe_init)
@tupui
tupui / sobol_convergence.py
Last active February 5, 2021 07:48
Integration convergence using Sobol' sequence: removing the first point
"""Integration convergence using Sobol' sequence: removing the first point.
Compute the convergence rate for integrating functions using Sobol' low
discrepancy sequence [1]_. We are interested in measuring the effect of
removing the first point of the sequence ([0, ...]).
Two sets of functions are considered:
(i) The first set of functions are synthetic examples specifically designed
to verify the correctness of the implementation [3]_.
@tupui
tupui / halton_convergence.py
Last active July 20, 2021 17:37
Integration convergence using Halton sequence: scrambling effect
"""Integration convergence using Halton sequence: scrambling effect.
Compute the convergence rate for integrating functions using Halton low
discrepancy sequence [1]_. We are interested in the effect of scrambling [2]_.
Two sets of functions are considered:
(i) The first set of functions are synthetic examples specifically designed
to verify the correctness of the implementation [4]_.
@tupui
tupui / benford.py
Created November 19, 2020 16:04
Benford's law to measure random number generation quality
"""Benford's law to measure random number generation quality.
.. note:: This script relies on a modified version of scipy. Pull Request:
https://github.com/scipy/scipy/pull/10844
---------------------------
MIT License
Copyright (c) 2020 Pamphile Tupui ROY
@tupui
tupui / joint_distribution.py
Last active October 2, 2021 16:03
Sampling a joint distribution with a copula
"""Sampling a joint distribution with a copula.
A copula describes the dependency between the marginal
distributions. Using the copula, you can sample from a
joint distribution.
---------------------------
MIT License
@tupui
tupui / sobol_bit_generator.py
Last active April 13, 2021 14:45
Sobol' as a numpy.random.Generator
"""Sobol' as a numpy.random.Generator.
.. note:: This script relies SciPy >1.7
---------------------------
MIT License
Copyright (c) 2021 Pamphile Tupui ROY
@tupui
tupui / lloyd_sampling.py
Last active August 9, 2021 05:40
Centroidal Voronoi Tessellation to generate sample: Lloyd's algorithm
"""Centroidal Voronoi Tessellation to generate sample: Lloyd's algorithm.
Based on the implementation of Stéfan van der Walt
https://github.com/stefanv/lloyd
which is:
Copyright (c) 2021-04-21 Stéfan van der Walt https://github.com/stefanv/lloyd
MIT License
@tupui
tupui / olhs_sampling.py
Last active August 9, 2021 15:50
Orthogonal Latin Hypercube Sampling
"""Orthogonal Latin Hypercube Sampling.
---------------------------
MIT License
Copyright (c) 2021 Pamphile Tupui ROY
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@tupui
tupui / mcm2021_scipy_pytorch_demo.ipynb
Last active August 16, 2021 17:18
MCM 2021 Scipy and Pytorch demo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tupui
tupui / poisson_disk_sampling.py
Last active January 28, 2022 10:44
Poisson disk sampling in n-dimensions
"""Poisson disk sampling in n-dimensions.
This is part of an effort to add Poisson disk sampling into SciPy:
https://github.com/scipy/scipy/pull/13918
---------------------------
MIT License