User:SonnaGab/ավազարկղ

An illustration of Monte Carlo integration. In this example, the domain D is the inner circle and the domain E is the square. Because the square's area can be easily calculated, the area of the circle can be estimated by the ratio (0.8) of the points inside the circle (40) to the total number of points (50), yielding an approximation for

Մաթեմատիկայում, Monte Carlo ինտեգրացիան թվային ինտեգրացիա է,որը օգտագործում է պատահական թվեր. Այսինքն, Monte Carlo ինտեգրման մեթոդները ալգորիթմների համար որոշակի ինտեգրալների մոտավոր գնահատումն է, սովորաբար մի քանի multidimensional: Սովորական ալգորիթմները գնահատում են ներառելով հերթական grid. Monte Carlo մեթոդները, սակայն, պատահականորեն ընտրում են կետերը, որով ներառվածը գնահատվում է:

Պաշտոնապես, ինչպես գնահատել D դաշտը, նախ ընտրեք այն պարզ դաշտ E-ն,որի տարածքը հեշտությամբ հաշվարկվում եւ որը պարունակում է D: Այժմ պատահական հաջորդականությամբ ընկնում է E-ին մոտ: Որոշ կոտորակներ ընկնում են D-ին մոտ: D դաշտը գնահատվում է, ապա այս մասն բազմապատկվում է E դաշտի կողմից:

Ավանդական Monte Carlo ալգորիթմը տարածում է գնահատման միավորը uniformly ինտեգրման տարածաշրջանում: Հարմարվող ալգորիթմները, ինչպիսիք են VEGAS և MISER օգտագործում են կարեւորն նմուշառում և stratified նմուշառում տեխնիկայի ավելի լավ արդյունք ստանալու համար:

Պարզ Monte Carlo ինտեգրացիա ալգորիթմը

edit

Պարզ Monte Carlo ինտեգրման ալգորիթմը հաշվարկում է multidimensional որոշակի անբաժան նախահաշիվը, որը այս ձևով է,

 

where   and the hypercube   is the region of integration,

 .

Բայց ստորեւ մենք պետք է օգտագործենք   մատնանշելով այս տարածաշրջանի չափումը:

Իսկ ալգորիթմի նմուշների միավորները միասնական են ինտեգրման տարածաշրջանից գնահատելով այն ամբողջական և իր սխալը. Ենթադրենք, որ նմուշ ունի չափ   եւ այդ նմուշի միավորները մատնանշվում են   կողմից : Այնուհետեւ ինտեգրալի նախահաշիվը տրվում է

 ,

Որտեղ   նշանակում է integrand-ի նմուշ.   հետեւում է այն փաստը, որ   ինտեգրման շրջանի equidistributed հաջորդականությունը (անտեսելով իրականացման հարցեր, ինչպիսիք են pseudorandom գեներատորների շարքը եւ սահմանափակ ճշգրտության լողացող կետը).

Integrand-ի sample variance կարելի է գնահատել, օգտագործելով

 

Որտեղ օգտագործվում է    -ի փոխարեն, որպեսզի ստանան unbiased estimate of the variance:

Քանի որ հետեւյալ ուժի մեջ է ցանկացած անկախ փոփոխականների stochastic  ,

 ,

եւ քանի որ, որպես մշտական   ունի հետեւյալ գույքը,

 ,

Ապա ինտեգրալի գնահատականների փոփոխությունը

 .

Քանի դեռ հաջորդականությանը  սահմանափակ է, այդ փոփոխությունը նվազեցնում է asymptotically մինչեւ զրո, ինչպես  . Սխալ նախահաշիվը,

 

Նվազում են, ինչպես  . պատահական զբոսանք ծանոթ օրենքը տարածվում է: նվազեցնում է սխալը 10 գործոնից 100- ապատիկի չափով թվի աճ:

Վերը արտահայտությունն ապահովում է վիճակագրական գնահատական սխալի մասին. Արդյունքում, այս հաշվարկը սխալ չէ, խիստ սխալ է կարված; տարածաշրջանի պատահական ընտրանքը չի կարող բացահայտել բոլոր կարեւոր հատկանիշները, որոնք գործում են, ինչի արդյունքում է թերագնահատում է այդ սխալը:

Recursive stratified sampling

edit

Recursive stratified նմուշառումը մեկ տարածական ընդհանրացում է հարմարվող քառակուսու բազմակողմ ինտեգրալի հետ. Յուրաքանչյուր ռեկուրսի քայլ ամբողջական է եւ սխալ է գնահատվում օգտագործելով պարզ Monte Carlo ալգորիթմը. Եթե նախահաշիվի սխալը ավելի մեծ է, քան պահանջվող ճշգրտության ինտեգրումը, ծավալը բաժանվում է ենթահաշիվների ծավալների եւ այդ ընթացակարգը կիրառվում է վերադարձում ենթահաշիվների ծավալներով.

Սովորական ' երկուի բաժանարար ' ռազմավարությունը չի աշխատում բազմամյա հարթություններում, քանի որ ենթահաշիվներից մի շանիսի ծավալները աճում են, շատ արագ ուղին չկորցնելով: Մեկ գնահատականների փոխարեն, որոնց ստորաբաժանումը բերում է ամենաշատ շահաբաժինները եւ միայն այս հարթության ստորաբաժանումի ծավալի երկայնքով:

Ահա տիպիկ ալգորիթմ recursive stratified sampling-ի համար:

Sample   random points;
Estimate the average and the error;
If the error is acceptable :
   Return the average and the error;
Else :
   For each dimension :
      Subdivide the volume in two along the dimension;
      Estimate the sub-averages in the two sub-volumes;
   Pick the dimension with the largest sub-average;
   Subdivide the volume in two along this dimension;
   Dispatch two recursive calls to each of the sub-volumes;
   Estimate the grand average and grand variance;
   Return the grand average and grand variance;

Շերտադասվել նմուշառումի ալգորիթմի խտանյութերը ստուգում է կետերը մարզերում, որտեղ գործառույթի անհամաձայնությունը խոշորագույնն է, այդպիսով նվազեցնելով մեծ վեճ ու դարձնելով առավել արդյունավետ նմուշառում , ինչպես լուսաբանվում է:

Լուսաբանելու համար կետերը գեներացվել են հետևյալ կերպ JavaScript-1.8 implementation վերը նշված ալգորիթմի իրականացումը,

 function strata(f,a,b,acc,eps,N,aold,vold,nold,V)
 {
 if(typeof(N)=="undefined")N=42; // the number of points to be added at each recursion
 var randomx = function(a,b) [a[i]+Math.random()*(b[i]-a[i]) for (i in a)]
 var range   = function(n) {for(var i=0;i<n;i++) yield i}
 var stats   = function(xs){ // statistics
   var xmean=xs.reduce(function(a,b)a+b,0)/xs.length
   var sigma2=xs.reduce(function(a,b)a+b*b,0)/xs.length-Math.pow(xmean,2) 
   return [xmean,Math.sqrt(sigma2),xs.length]
   }
 if(typeof(aold)=="undefined"){ // first call: setting up 'old' values
   var V=1; for(let k in a) V*=(b[k]-a[k])
   let xs=[randomx(a,b) for(i in range(N))]
   let ys=[f(x) for each (x in xs)]
   var [aold,vold,nold]=stats(ys)
   }
 var xs=[randomx(a,b) for(i in range(N))] // new points
 var ys=[f(x) for each (x in xs)]         // new function values
 var [av,va,]=stats(ys)                    // average and variance
 var integ=V*(av*N+aold*nold)/(N+nold)    // integral and error
 var error=V*Math.sqrt( (va*va*N+vold*vold*nold)/(N+nold)/(N+nold) )
 if(error<acc+eps*Math.abs(integ)) return [integ,error]; // done
 else{ // not done: need to dispatch a recursive call
   var vmax=-1, kmax=0
   for(let k in a){ // look in all dimensions for which is best to bisect
      var [al,vl,nl]=stats([ys[i] for(i in xs)if(xs[i][k]< (a[k]+b[k])/2)])
      var [ar,vr,nr]=stats([ys[i] for(i in xs)if(xs[i][k]>=(a[k]+b[k])/2)])
      var v=Math.abs(al-ar) // take the one with largest variation
      if(v>vmax){ // remember the values
         vmax=v;kmax=k;
         var alo=al, vlo=vl, nlo=nl; var aro=ar, vro=vr, nro=nr
      }
   } // now dispatch two recursive calls
   let a2=a.slice(); a2[kmax]=(a[kmax]+b[kmax])/2
   let b2=b.slice(); b2[kmax]=(a[kmax]+b[kmax])/2
   let [i1,e1]=strata(f,a,b2,acc/1.414,eps,N,alo,vlo,nlo,V/2)
   let [i2,e2]=strata(f,a2,b,acc/1.414,eps,N,aro,vro,nro,V/2)
   return [i1+i2,Math.sqrt(e1*e1+e2*e2)] // return results
   }
 }
 var points=[]
 var fun=function([x,y]){
    points.push([x,y])
    return x*x+y*y<1 ? 1:0
    }
 var a=[-1,-1], b=[1,1]
 var acc=eps=0.5e-2
 var [q,err]=strata(fun,a,b,acc,eps,32)
 print("# m=0, S=1")
 for each(var [x,y] in points) print(x,y)

Այսօր հայտնի ԱԳԱՀ ռեժիմը իրականացնում է նմանատիպ մի ալգորիթմ:

ԱԳԱՀ Monte Carlo

edit

Press և Farrar ագահ ալգորիթմը հիմնված է recursive stratified sampling-ի վրա: Այս տեխնիկայի նպատակն է նվազեցնել ընդհանուր ինտեգրացիոն սխալը` կենտրոնացնելով ինտեգրացիոն միավորը ամենաբարձր շեղման մարզերում:

stratified sampling-ի գաղափարը սկսվում է դիտարկվել, որ երկու a և b շրջաններում, ինչպես նաեւ Monte Carlo-ում ինտեգրալի հաշվարկները   and   և գժտությունը   and  , իսկ գժտությունը   համակցված գնահատականներով   տրված է,

 

Կարելի է ցույց տալ, որ վեճը նվազագույնի է հասցվել բաշխման կետերի կողմից, օրինակ,

 

Hence the smallest error estimate is obtained by allocating sample points in proportion to the standard deviation of the function in each sub-region.

The MISER algorithm proceeds by bisecting the integration region along one coordinate axis to give two sub-regions at each step. The direction is chosen by examining all d possible bisections and selecting the one which will minimize the combined variance of the two sub-regions. The variance in the sub-regions is estimated by sampling with a fraction of the total number of points available to the current step. The same procedure is then repeated recursively for each of the two half-spaces from the best bisection. The remaining sample points are allocated to the sub-regions using the formula for N_a and N_b. This recursive allocation of integration points continues down to a user-specified depth where each sub-region is integrated using a plain Monte Carlo estimate. These individual values and their error estimates are then combined upwards to give an overall result and an estimate of its error.

This routines uses the MISER Monte Carlo algorithm to integrate the function f over the dim-dimensional hypercubic region defined by the lower and upper limits in the arrays xl and xu, each of size dim. The integration uses a fixed number of function calls, and obtains random sampling points using the random number generator r. A previously allocated workspace s must be supplied. The result of the integration is returned in result, with an estimated absolute error abserr.

Ուրվագծված պարամետրեր

edit

ԱԳԱՀ ալգորիթմը ունի մի քանի ուրագծված պարամետրեր:

estimate_frac

edit

Այս պարամետրը սահմանում է կոտորակ, որը ներկայումս առկա մի շարք զանգերի ֆունկցիայում, որոնք հատկացված է գնահատելու յուրաքանչյուր վերադարձաց քայլի շեղվում: Իսկ GNU Գիտական Գրադարանի (GSL) իրականացման նախնական արժեքը 0.1 է:

min_calls

edit

Այս պարամետրը սահմանում է զանգերի ֆունկցիայի նվազագույն քանակը, որից յուրաքնաչյուրը շեղվում է հաշվարկի մեջ: Եթե ֆունկցիայի համարի կոչերը հատկացված են գնահատականներով, օգտագործելով estimate_frac ընկնում է ներքև min_calls ապա օգնագործում ենք min_calls-ի փոխարեն: Սա երաշխավորում է, որ յուրաքանչյուր նախահաշիվը պահպանվում է ողջամիտ մակարդակի ճշգրտությամբ: GNU գիտական գրադարանի իրականացումը, min_calls-ի նախնական արժեքը 16 * dim է:

min_calls_per_bisection

edit

Այս պարամետրը սահմանում է զանգերի ֆունկցիայի նվազագույն քանակը, որը շարունակել է այն կիսում քայլի հետ: Երբ վերադարձ քայլը ունի ավելի քիչ զանգեր, քան առկա min_calls_per_bisection-ը, այն կատարում է պարզ Monte Carlo ընթացիկ ենթահանձնաժողովների նախահաշիվը տարածաշրջանում եւ դադարեցնում է իր մասնաճյուղի ռեկուրսիան: GNU գիտական գրադարանի իրականցումը ,պարամետրի նախնական արժեքը 32 * min_calls է:

alpha

edit

Այս պարամետրը վերահսկում է, թե ինչպես գնահատած անհամաձայնությունների համար երկու ենթահաշիվների շրջաններից մեկը համակցված կիսում է,երբ հատկացվում է միավոր: Անհամաձայության ընտրանքի ընդհանուր գժտությունում լայնածավալը ավելի լավ է, քան 1/N-ում, քանի որ ենթահանձնաժողովների շրջաններիվ նախատեսված արժեքները ձեռք են բերել օգտագործման կարգը, որով հստակորեն նվազեցնում են իրենց շեղվումը: Այս պահվածքի տեղավորելը թույլ է տալիս ԱԳԱՀ ալգորիթմի ընդհանուր գժտություն, որը կախված է մի չափման պարամետրից \ ալֆաից,

 

Սկզբնական թղթի հեղինակները բնութագրում են ԱԳԱհ խորհուրդի արժեքը   որպես լավ ընտրություն է, ստացված թվային փորձերից, եւ դա օգտագործվում է որպես լռելյայն արժեք GNU գիտական գրադարանի իրականացումում:

dither

edit

Այս պարամետրը ներկայացնում է պատահական կոտորակային տատանումների չափի dither յուրաքանչյուր կիսումում, որը կարելի է օգտագործել կոտրելու ինտեգրալների սիմետրիան, որոնք կենտրոնացած են hypercubic ինտեգրման տարածաշրջանի կենտրոնին շատ ճշգրիտ. GNU գիտական գրադարանի իրականացումում, dither-ի նախնական արժեքը զրոյական է, այնպես որ ոչ մի փոփոխություն չի ներկայացվել: Անհրաժեշտության դեպքում dither-ի տիպիկ արժեքը մոտ 0.1-ին:

Կարեւոր նմուշառումը

edit

VEGAS Monte Carlo

edit

G.P.Lepage-ի iVEGAS ալգորիթմը հիմնված է Կարեւոր նմուշառումի վրա: Այն հավանականության բաշխման նմուշների միավորը նկարագրված է ֆունկցիային  , որի կետերը կենտրոնացած են մարզերում, որոնք ինտեգրալ ամենամեծ ներդրումն էր:

Ընդհանրապես, եթե Monte Carlo անբաժան է   օրինակ, հավանականության բաշխումը նկարագրվում է ֆունկցիայի կողմից  , մենք ստանալու ենք գնահատական  ,

 

ինչպես նաեւ համապատասխան գործավարությանը,

 

Եթե բաշխման հավանականությունը ընտրված է որպես   ապա կարելի է ցույց տալ գործավարության variance   անհետանալը, սխալ գնահատականները կլինեն զրո: Գործնականում հնարավոր չէ բաշխման նմուշից   կամայական գործողության համար, այսպես կարեւորության ստուգման ալգորիթմների նպատակն է արտադրել արդյունավետ ցանկալի մոտեցում:

The VEGAS algorithm approximates the exact distribution by making a number of passes over the integration region while histogramming the function  . Each histogram is used to define a sampling distribution for the next pass. Asymptotically this procedure converges to the desired distribution. In order to avoid the number of histogram bins growing like   the probability distribution is approximated by a separable function:   so that the number of bins required is only  . This is equivalent to locating the peaks of the function from the projections of the integrand onto the coordinate axes. The efficiency of VEGAS depends on the validity of this assumption. It is most efficient when the peaks of the integrand are well-localized. If an integrand can be rewritten in a form which is approximately separable this will increase the efficiency of integration with VEGAS.

VEGAS-ը ներառում է մի շարք լրացուցիչ հնարավորություններ,և համատեղում է և stratified sampling և ստուգման կարեւորությունը: Շրջանի ինտեգրումը բաժանված է մի շարք " արկղերի ", յուրաքանչյուր վանդակում ստանալու կայուն միավոր (նպատակը 2): Յուրաքանչյուր արկղ կարող է ունենալ կոտորակային շարքեր, բայց եթե արկղերը երկուսից պակաս են, Vegas-ը կրճատում է շեղումը ( այլ ոչ թե կարեւոր նմուշառումը):

This routines uses the VEGAS Monte Carlo algorithm to integrate the function   over the dim-dimensional hypercubic region defined by the lower and upper limits in the arrays   and  , each of size  . The integration uses a fixed number of function calls, and obtains random sampling points using the random number generator  . A previously allocated workspace   must be supplied. The result of the integration is returned in  , with an estimated absolute error  . The result and its error estimate are based on a weighted average of independent samples. The chi-squared per degree of freedom for the weighted average is returned via the state struct component,  , and must be consistent with 1 for the weighted average to be reliable.

The VEGAS algorithm computes a number of independent estimates of the integral internally, according to the iterations parameter described below, and returns their weighted average. Random sampling of the integrand can occasionally produce an estimate where the error is zero, particularly if the function is constant in some regions. An estimate with zero error causes the weighted average to break down and must be handled separately. In the original Fortran implementations of VEGAS the error estimate is made non-zero by substituting a small value (typically 1e-30). The implementation in GSL differs from this and avoids the use of an arbitrary constant -- it either assigns the value a weight which is the average weight of the preceding estimates, or discards it according to the following procedure:

  • Current estimate has zero error, weighted average has finite error
    The current estimate is assigned a weight which is the average weight of the preceding estimates.
  • Current estimate has finite error, previous estimates had zero error
    The previous estimates are discarded and the weighted averaging procedure begins with the current estimate.
  • Current estimate has zero error, previous estimates had zero error
    The estimates are averaged using the arithmetic mean, but no error is computed.

Ուրվագծված պարամետրեր

edit

VEGAS ալգորիթմը ուրվագծված է:

chisq

edit

Այս պարամետրը տալիս էchi-squared-ի մեկ աստիճան ազատություն ինտեգրալի գնահատման համար: Chisq-ի արժեքը տետք է մետ լինի 1-ի. Chisq-ի արժեքը, որը զգալիորեն տարբերվում է 1-ից, նշենք, որ տարբեր iterations արժեքները անհետեւողական են: Այս դեպքում կշռված սխալը գնահատվում է եւ հետագա iterations ալգորիթմը անհրաժեշտ է ձեռք բերել հուսալի արդյունքներ:

alpha

edit

alpha պարամետրը վերահսկում է rebinning ալգորիթմի stiffness: Այն սովորաբար սահմանվում է մեկ եւ երկուսի միջև: Զրո արժեքը խանգարում է rebinning grid: GNU գիտական գրադարանի իրականացման նախնական արժեքը 1.5:

iterations

edit

iterations թիվը կատարում է յուրաքանչյուր զանգի ռեժիմի վրա: GNU գիտական գրադարանի իրականացման նախնական արժեքը 5 iterations:

stage

edit

Setting this determines the stage of the calculation. Normally, stage = 0 which begins with a new uniform grid and empty weighted average. Calling vegas with stage = 1 retains the grid from the previous run but discards the weighted average, so that one can "tune" the grid using a relatively small number of points and then do a large run with stage = 1 on the optimized grid. Setting stage = 2 keeps the grid and the weighted average from the previous run, but may increase (or decrease) the number of histogram bins in the grid depending on the number of calls available. Choosing stage = 3 enters at the main loop, so that nothing is changed, and is equivalent to performing additional iterations in a previous call.

mode

edit

Հնարավոր ընտրություններ են GSL_VEGAS_MODE_IMPORTANCE, GSL_VEGAS_MODE_STRATIFIED, GSL_VEGAS_MODE_IMPORTANCE_ONLY: Այս սահմանում VEGAS-ը կօգտագործի կարեւորության նմուշառումը կամ շերտ-շերտ կազմած ստուգումը, կամ արդյոք այն կարող է վերցնել իր սեփականը: Ցածր հարթություններում VEGAS-ը օգտագործում խիստ է շերտ-շերտ կազմած ստուգումը (ավելի ճիշտ, շերտ-շերտ դասված նմուշառումը ընտրվում է, եթե մեկ արկղում առկա է 2-ից պակաս արկղ):

Տես նաև

edit

Հիշատակում եւ հետագա ընթերցանություն

edit

Հետեւյալ հղում Monte Carlo-յի մասին և quasi-Monte Carlo մեթոդները ընդհանրապես (ինչպես նվազեցման տեխնիկայի շեղման նկարագրության մեջ) հիանալի է սկսել.

  • R. E. Caflisch, Monte Carlo and quasi-Monte Carlo methods, Acta Numerica vol. 7, Cambridge University Press, 1998, pp. 1-49.

Nice survey on arXiv, based on lecture for graduate students in high energy physics:

The MISER algorithm is described in the following article,

  • W.H. Press, G.R. Farrar, Recursive Stratified Sampling for Multidimensional Monte Carlo Integration, Computers in Physics, v4 (1990), pp190-195.

The VEGAS algorithm is described in the following papers,

  • G.P. Lepage, A New Algorithm for Adaptive Multidimensional Integration, Journal of Computational Physics 27, 192-203, (1978)
  • G.P. Lepage, VEGAS: An Adaptive Multi-dimensional Integration Program, Cornell preprint CLNS 80-447, March 1980

Early works:

  • J. M. Hammersley, D.C. Handscomb (1964) Monte Carlo Methods. Methuen. ISBN 0-416-52340-4

A general discussion, including both MISER and VEGAS and comparing them, is at


Based on the GNU Scientific Library's manual, which is published under the GFDL (and hence free to use for Wikipedia). Original available here.

edit

Category:Monte Carlo methods