https://github.com/landerlini/multigaussampler
Sampling from a Maximum-Likelihood fitted Multi-Gaussian distribution in TensorFlow 2.1
https://github.com/landerlini/multigaussampler
maximum-likelihood-estimation monte-carlo-simulation resampling simulation
Last synced: 5 months ago
JSON representation
Sampling from a Maximum-Likelihood fitted Multi-Gaussian distribution in TensorFlow 2.1
- Host: GitHub
- URL: https://github.com/landerlini/multigaussampler
- Owner: landerlini
- License: mit
- Created: 2020-04-03T05:59:22.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-25T00:21:03.000Z (over 3 years ago)
- Last Synced: 2024-08-08T19:57:04.718Z (almost 2 years ago)
- Topics: maximum-likelihood-estimation, monte-carlo-simulation, resampling, simulation
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Multi-Gaussian Sampling
The parametrization of conditional probability density function plays a crucial
role in the simulations used to produce quickly large samples of data emulating
real-life datasets.
A very simple technique is based on the explicit modelling of the probability
density function of the target dataset as a function of the conditions through
the sum of kernel functions.
The package`multigaussampler` offers a simple Python3 implementation of this
simple algorithm. The model of the `pdf` is obtained through a maximum
likelihood fit of a probability density function obtained as sum of
Gaussians, optimized using the TensorFlow implementation of the Adam optimizer.
The sampling of the `pdf` is also implemented in TensorFlow to provide
efficient sampling on both CPU and GPU infrastructures.
### Example code
The code snippet below trains a sampler on a random dataset and generates
a random sample of y variables on top of the same X variables used for training.
```
import numpy as np
## Generate a random dataset as an example
nSamples = 1000
X = np.random.uniform ( -20, 10, (nSamples,4)).astype (np.float32)
y = np.random.uniform ( 0, 1, (nSamples,2)).astype (np.float32)
#from multigaussampler import MGSampler
## Creates and configure the MGSampler object
gp = MGSampler(X,y)
## Train the MGSampler on the training dataset
from tqdm import trange
progress_bar = trange ( 100 )
for iEpoch in progress_bar:
l = gp.train ( X,y )
progress_bar.set_description ( "Loss: %.1f " % l )
## Sample the obtained parametrization
gp.sample (X)
```
### Author
Lucio Anderlini (Istituto Nazionale di Fisica Nucleare)