Skip to content

wikko75/Integral-Approximation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Integral-Approximation

Using the Monte Carlo method.

Algorithm steps:

  1. Generate independently and uniformly n points from a rectangle [a, b] x [0, M]
    for a given M >= sup{ f(x) : x ∈ [a,b] }
  2. Count a number of generated points that lay under the curve of a function f(x)
    A point (x, y) lies under the curve of f(x) if y <= f(x) ( = C )
  3. The approximation is C/n * ( b−a ) * M, where ( b−a ) * M is an area of the rectangle

Sample Result:

  • f(x) = x^1/3

  • a = 0
    b = 8
    M = 3

    Which gives: [0, 8] x [0, 3]

  • Blue points - repeats of the algorithm for a given n

  • Red points - an average value of repeats for a given n

    Figure_2

  • The actual value of such integral of f(x) is 12!

About

Integral Approximation with the Monte Carlo method

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages