Rank: 4268 based on 5 downloads (last 30 days) and 1 file submitted
photo

Clement Bernard

E-mail

Personal Profile:
Professional Interests:
sensors, instrumentation

 

Watch this Author's files

 

Files Posted by Clement
Updated   File Tags Downloads
(last 30 days)
Comments Rating
11 Jun 2008 Montecarlo simulation estimation of pi, using montecarlo method Author: Clement Bernard montecarlo, pi, stochastic, mathematics, general 5 5
  • 1.25
1.2 | 4 ratings
Comments and Ratings on Clement's Files View all
Updated File Comment by Comments Rating
12 Jun 2008 Montecarlo simulation estimation of pi, using montecarlo method Author: Clement Bernard D'Errico, John

No, this is not Marco "poor". But Marco really deserves a rating of -10 (pure dreck). This submission is still poor, although I'd be willing to give it a rating of about 1.25 if we could use a continuous scale for our ratings.

Why does this still deserve an rating of poor?

It is a script. As such it does not do anything useful for a user except as a teaching tool. And as a teaching tool, it is poor.

The code is amateurish, using command line input, a poor thing to teach others to use. It does things like overwrite the variable pi, a terribly poor thing to do, especially when the action is in a script! In fact, pi should never be overwritten as a variable. The author should also learn to use better variable names. A,B,C,e,p are completely arbitrary names, that tell the reader NOTHING about them. In a script that can have meaning ONLY as a teaching device, it is most important to use meaningful names.

The author needs to learn to write self-documenting code. This means to use variable names that actually mean SOMETHING. At the very least, put in a line of comment before each variable gets created that explains what was done.

Heinrich points out some of the many things that should be done better, so I won't re-list them all. There are others though. For example, the line

theta = 0:.1:2.*pi;

has theta running just short of pi, so the circle has a break in it. Better would have been to use linspace, creating a complete circle.

Even the last line of code is what I'd call poor. Why compute a relative deviation using the sqrt of a square of a difference between scalars?

dev = (sqrt((PI - pi).^2)/pi).*100

There is a new function in Matlab that does the same thing more efficiently, as well as more accurately. It is called abs, for absolute value. I don't know if this is found in all releases of matlab.

Even beyond the above comments, the code itself is pretty trivial.

For me, this just needs way too huge an amount of improvement to qualify as a 2.

12 Jun 2008 Montecarlo simulation estimation of pi, using montecarlo method Author: Clement Bernard x@y.z, Jos

The reason I rated this as poor, is the following: this submission is understandable only for people who already know matlab and their maths. For everybody else this is completely above their head. I do not want to say that the idea is poor, it is just poorly implemented. Nobody will use this as it is

In my opinion it is not worth it to improve this submission, and I advise the author to start from scratch, after getting some more matlab skills. Remember that even the most professional programmer has written something like this when they were just starting, so do not be disencouraged. But learning to program doesn't mean you have to share everything you write.

12 Jun 2008 Montecarlo simulation estimation of pi, using montecarlo method Author: Clement Bernard Acker, Heinrich

I don't agree that this should be rated as 1 (=poor=Marco) just for being a simple demo of a well-known method. Positive about this contribution are:
- it works
- it can be useful as a demo for a method not everybody learns in kindergarten
- it has sufficient comments to allow the user to understand the method

It needs improvement, however:
- there should be line-by-line comments
- pi should be written as 'pi', it is displayed as '?' here
- the line 'pi=pi' doesn't make much sense
- why display axis([-1 1 -1 1]) if only one quadrant is used?
- 'axis equal' would make a circle look like a circle
- using smaller marker size would shift the problem that the points are shown as a blue square to higher n
- a demo would also benefit from better variable names

11 Jun 2008 Montecarlo simulation estimation of pi, using montecarlo method Author: Clement Bernard x@y.z, Jos

This needs much more internal comments, help, graphical output, etc. to be even slighly of interest as a (rather trivial) demonstration. Also make it a function like every proper demo in matlab.

11 Jun 2008 Montecarlo simulation estimation of pi, using montecarlo method Author: Clement Bernard Shvorob, Dimitri

This would impress in a kindergarten.

Top Tags Applied by Clement
general, mathematics, montecarlo, pi, stochastic
Files Tagged by Clement
Updated   File Tags Downloads
(last 30 days)
Comments Rating
11 Jun 2008 Montecarlo simulation estimation of pi, using montecarlo method Author: Clement Bernard montecarlo, pi, stochastic, mathematics, general 5 5
  • 1.25
1.2 | 4 ratings

Contact us at files@mathworks.com