Multiple Runs
This commit is contained in:
@@ -1,24 +1,31 @@
|
|||||||
tic;
|
tic;
|
||||||
samples = 10000000;
|
samples = 100000;
|
||||||
xBounds = LinearBounds(0,20);
|
xBounds = LinearBounds(0,20);
|
||||||
yBounds = LinearBounds(-10,150000);
|
yBounds = LinearBounds(-10,150000);
|
||||||
bounds = Bounds(xBounds,yBounds);
|
bounds = Bounds(xBounds,yBounds);
|
||||||
pointsInside = 0;
|
pointsInside = 0;
|
||||||
realValue = realIntegral(bounds.x);
|
realValue = realIntegral(bounds.x);
|
||||||
|
listOfErrors = [];
|
||||||
|
listOfIntegrals = [];
|
||||||
|
|
||||||
for i = 0:samples
|
for i = 1:20
|
||||||
|
for ii = 0:samples
|
||||||
toTestPoint = bounds.getRandomPoint;
|
toTestPoint = bounds.getRandomPoint;
|
||||||
if getIsInside(toTestPoint)
|
if getIsInside(toTestPoint)
|
||||||
pointsInside = pointsInside+1;
|
pointsInside = pointsInside+1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
listOfIntegrals(i) = pointsInside/samples*bounds.area;
|
||||||
|
listOfErrors(i) = abs(listOfIntegrals(i) - realValue);
|
||||||
|
pointsInside = 0;
|
||||||
|
end
|
||||||
|
|
||||||
format longG
|
format longG
|
||||||
integral = (pointsInside/samples)*bounds.area
|
integral = (pointsInside/samples)*bounds.area
|
||||||
realValue
|
realValue
|
||||||
error = abs(realValue-integral)
|
error = abs(realValue-integral)
|
||||||
samples
|
listOfErrors
|
||||||
|
listOfIntegrals
|
||||||
toc
|
toc
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user