ball-blog
  • Welcome, I'm ball
  • Machine Learning - Basic
    • Entropy
    • Cross Entropy
    • KL-Divergence
    • Monte-Carlo Method
    • Variational Auto Encoder
    • SVM
    • Adam Optimizer
    • Batch Normalization
    • Tokenizer
    • Rotary Positional Encoding
    • Vector Quantized VAE(VQ-VAE)
    • DALL-E
    • Diffusion Model
    • Memory Layers at Scale
    • Chain-of-Thought
  • Einsum
  • Linear Algebra
    • Linear Transformation
    • Determinant
    • Eigen-Value Decomposition(EVD)
    • Singular-Value Decomposition(SVD)
  • AI Accelerator
    • CachedAttention
    • SGLang
    • CacheBlend
  • Reinforcement Learning
    • Markov
  • Policy-Improvement Algorithm
  • Machine Learning - Transformer
    • Attention is All you need
    • Why do we need a mask in Transformer
    • Linear Transformer
    • kr2en Translator using Tranformer
    • Segment Anything
    • MNIST, CIFAR10 Classifier using ViT
    • Finetuning PaliGemma using LoRA
    • LoRA: Low-Rank Adaptation
  • EGTR: Extracting Graph from Transformer for SGG
  • Machine Learning - Mamba
    • Function Space(Hilbert Space)
    • HIPPO Framework
    • Linear State Space Layer
    • S4(Structures Space for Sequence Model)
    • Parallel Scan Algorithm
    • Mamba Model
  • Computer System
    • Memory Ordering: Release/Acquire 1
    • Memory Ordering: Release/Acquire 2
    • BUDAlloc
    • Lock-free Hash Table
    • Address Sanitizer
  • App development
    • Bluetooth connection in linux
    • I use Bun!
    • Using Tanstack-query in Frontend
    • Deploying AI Service using EC2
  • Problem Solving
    • Bipartite Graph
    • Shortest Path Problem in Graph
    • Diameter of a Tree
  • Scribbles
Powered by GitBook
On this page
  • When do we use Monte-Carlo Method?
  • What is Monte-Carlo Method?
  • Estimate the value of using Monte-Carlo Method

Was this helpful?

Edit on GitHub
  1. Machine Learning - Basic

Monte-Carlo Method

Last updated 3 months ago

Was this helpful?

When do we use Monte-Carlo Method?

Let's say we don't know the parameters of Gaussian distribution P, but we can sample as much as we want.

Gaussian distribution has two parameters: mean μ\muμ and standard deviation σ\sigmaσ

We can use Monte-Carlo Method at this situation!

What is Monte-Carlo Method?

Monte-Carlo Method is a way to get information about the distribution using lots of sampling.

At the example above, we can sample 1,000,000,000 times to get the mean and std of the distribution P. There may be some errors, but as # of sampling gets bigger, error gets smaller.

Estimate the value of π\piπ using Monte-Carlo Method

The circle with radius 1 has area of π\piπ.

We are going to do 1,000,000,000 sampling in the range of x∈[−2,2],y∈[−2,2]x \in [-2, 2], y \in [-2, 2]x∈[−2,2],y∈[−2,2]

We are going to say, the sample point is inside the circle if x2+y2≤1x^2+y^2 \le1x2+y2≤1

If N out of 1,000,000,000 points are inside the circle, then we can estimate the π\piπ as follows:

π=N1,000,000,000⋅4≈3.14\pi = \frac{N}{1,000,000,000} \cdot 4\approx 3.14π=1,000,000,000N​⋅4≈3.14
Monte-Carlo simulation to estimate π\piπ