Академический Документы
Профессиональный Документы
Культура Документы
The area of the circle and the area of the square have approximately the same ratio
as the number of points in the circle to the number of points in the square.
But the typical combination, declaration and definition of an array can be done by the
zeros command.
10
For really big amounts of points, the plot is not very useful. Therefore only the picalculating part is done.
11
Comparing C-style to vectoring style, the vectoring style is a little bit faster.
12
But when stepping to even more points, the vectoring approach can cause out of
memory errors, as very big arrays have to be generated. N=1E9 worked for the C-style
code only on my machine.
13
14
15
16
17
18
19
20
21
22
23
The first and the last line of this code are used to measure the cpu-time for the
program.
24
In line two the number of families is hard coded , this means the user of the
program is not asked a number, but the number is written into the code.
25
Randi in lines 3-6 is the random number generator for discrete uniform distributions.
26
Note the bitwise logical operators | and & in line 7 and 8. You might have tried .|| or
.&& which might give the same result if they were defined within Matlab.
The bitwise &, | and == operators have arrays as operands and arrays as results. If the
conditions are met, the corresponding array element is 1, otherwise it is 0.
Nnz (read number of non zeros) then just counts the ones.
27
Note that the solution 0.48 clearly shows that the Tuesday information is important
(the strange point is, Wednesday would work as well, the day just has to be fixed).
Without the Tuesday, the probability of two boys would be only one third.
28
We have reached the end of our little problem solvers toolbox journey.
I hope you enjoyed it and will find it useful.
29
In fact we did cover a wide range of problems. Maybe after dealing with the tools and
some Matlab details this is a good time to step back to the modelling. Any model
reduces the worlds complexity, keeping phenomena that are important for the
problem at hand and forgetting about the rest. Like good managers do first things first
and second not all.
Think about which phenomena we kept, what were the phenomena we neglected or
didnt care about. (Like we did not care about the modulus of the gear wheels, or the
width of the gear wheels, or the material the gear box was made of. But we used the
non slipping assumption.) So this is goodbye from me, but maybe we will meet on the
discussion board or in our next Mooc, modelling and simulation using Simulink.
30