Python Programming for Biology: Bioinformatics and Beyond


Simple Monte Carlo integration



Download 7,75 Mb.
Pdf ko'rish
bet415/514
Sana30.12.2021
Hajmi7,75 Mb.
#91066
1   ...   411   412   413   414   415   416   417   418   ...   514
Bog'liq
[Tim J. Stevens, Wayne Boucher] Python Programming

Simple Monte Carlo integration

The first and simplest Python example that uses a Monte Carlo approach is one that aims

to perform integration, i.e. to determine the area bounded by some condition. Here we will

use a circle, and the result will not depend upon knowing what the value of the constant π

is. Indeed, this example actually provides a means of estimating a value for π, based upon

the measurement for the area of a circle. As illustrated in

Figure 25.2

, the method works

by taking a square area where x and y axis values range between −1 and 1. Random data

points (i.e. (x,y)  values)  are  added  to  this  square  and  then  the  number  of  points  that  fall

inside  a  circle  are  compared  to  the  total  number  of  points.  Here  it  is  easy  to  tell  which

points  are  inside  the  circle  because  they  will  be  within  a  fixed  distance  from  the  centre.

For this example this distance (the radius of the circle) is 1.0 and the centre is at the origin

of the coordinates. After a large number of points have been added, the number of points

that have randomly fallen inside the circle will be proportionate to the area of the circle.

This then leads to an estimation of the area compared to the total square, and thence to an

estimated value for π.




Download 7,75 Mb.

Do'stlaringiz bilan baham:
1   ...   411   412   413   414   415   416   417   418   ...   514




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish