## Archive for high school mathematics

## data is everywhere

Posted in Kids, pictures, Statistics, University life with tags CIRM, data, high school mathematics, les mercredis mathématiques du CIRM, Luminy, public lecture, Statistics, students, vulgarisation on November 25, 2018 by xi'an## métro static

Posted in Kids, Travel with tags high school mathematics, métro, Paris on March 26, 2014 by xi'an## \STATE [algorithmic package]

Posted in Books, Kids, pictures, R, Statistics, Travel, University life with tags algorithmic, AMSI, Australia, Beamer, high school mathematics, LaTeX, Monte Carlo Statistical Methods, pi, R, simulation on June 8, 2012 by xi'an**I** fought with my L^{α}T_{ε}X compiler this morning as it did not want to deal with my code:

\begin{algorithmic}[1] \STATE N=1000 \STATE $\hat\pi=0$ \FOR {I=1,N} \STATE X=RDN(1), Y=RDN(1) \IF {$\text{X}^2+\text{Y}^2<1$} $\hat\pi$ = $\hat\pi +1$ \ENDIF \ENDFOR \RETURN 4*$\hat\pi/$N \end{algorithmic}

looking on forums for incompatibilities between beamer and algorithmic, and adding all kinds of packages, to no avail. Until I realised one \STATE was missing:

\begin{algorithmic}[1] \STATE N=1000 \STATE $\hat\pi=0$ \FOR {I=1,N} \STATE X=RDN(1), Y=RDN(1) \IF {$\text{X}^2+\text{Y}^2<1$} \STATE $\hat\pi$ = $\hat\pi +1$ \ENDIF \ENDFOR \RETURN 4*$\hat\pi/$N \end{algorithmic}

(**T**his is connected with my AMSI public lecture on simulation, obviously!)

## cannonball approximation to pi

Posted in Statistics with tags Buffon's needle, computer language, high school mathematics, Monte Carlo methods, programmation, R on October 8, 2011 by xi'an**T**his year, my daughter started writing algorithms in her math class (she is in *seconde*, which could correspond to the 10th grade). The one she had to write down last weekend was Buffon’s neddle and the approximation of π by Monte Carlo (throwing cannon balls was not mentioned!). Here is the short R code I later wrote to show her the outcome (as the class has not yet learned a computer language):

n=10^6 counter=0 #uniforms over the unit square ray=runif(n)^2+runif(n)^2 #proportion within the quarter circle conv=cumsum((ray<1))/(1:n) plot(conv,type="l",col="steelblue",ylim=c(pi/4-2/sqrt(n), pi/4+2/sqrt(n)),xlab="n",ylab="proportion") abline(h=pi/4,col="gold3")

and here is an outcome of the convergence of the approximation to π/4: