Multiple Runs

This commit is contained in:
Parric007
2024-05-16 12:27:29 +02:00
parent 4a0994aceb
commit 9b122387d5

View File

@@ -1,24 +1,31 @@
tic;
samples = 10000000;
samples = 100000;
xBounds = LinearBounds(0,20);
yBounds = LinearBounds(-10,150000);
bounds = Bounds(xBounds,yBounds);
pointsInside = 0;
realValue = realIntegral(bounds.x);
listOfErrors = [];
listOfIntegrals = [];
for i = 0:samples
toTestPoint = bounds.getRandomPoint;
if getIsInside(toTestPoint)
pointsInside = pointsInside+1;
for i = 1:20
for ii = 0:samples
toTestPoint = bounds.getRandomPoint;
if getIsInside(toTestPoint)
pointsInside = pointsInside+1;
end
end
listOfIntegrals(i) = pointsInside/samples*bounds.area;
listOfErrors(i) = abs(listOfIntegrals(i) - realValue);
pointsInside = 0;
end
format longG
integral = (pointsInside/samples)*bounds.area
realValue
error = abs(realValue-integral)
samples
listOfErrors
listOfIntegrals
toc