```
<- function(p){
flips =0
x=0
nwhile(x==0){
=rbinom(1,1,p)
x=n+1
n
}
n
}= replicate(100000, flips(0.4))
sim mean(sim)
```

`[1] 2.49501`

`1/0.4`

`[1] 2.5`

Quarto is even fancier and possibly easier to use than R-markdown; it is run on RStudio, just like R-Markdown, and the coding is almost exactly the same, so that Rmd files can be compiled as qmd files with minor edits.

We simulate the amount of time it take for a head to appear, when tossing a bias coin.

```
<- function(p){
flips =0
x=0
nwhile(x==0){
=rbinom(1,1,p)
x=n+1
n
}
n
}= replicate(100000, flips(0.4))
sim mean(sim)
```

`[1] 2.49501`

`1/0.4`

`[1] 2.5`

We do the same experiment in Python,

```
import numpy as np
def flips(p):
=0
x=0
nwhile x==0:
=np.random.binomial(1,p,1)
x=n+1
nreturn n
= [flips(0.4) for _ in range(100000)]
sim print(np.mean(sim))
```

`2.49646`

`print(1/0.4)`

`2.5`

It appears that Quarto can easily handle Latex equation arrays *without* have the two dollar signs between the code, which allows for easier conversation into pdf.

Let \(U_1, U_2, \ldots\) be independent and uniformly distributed on the unit interval. By the law of large numbers and the change of variables formula, we have \[\begin{eqnarray*} \int_0 ^1 g(x) dx &=& \mathbb{E}g(U_1) \\ &=& \lim_{n \to \infty} \frac{1}{n} \sum_{i=1} ^n g(U_i) \end{eqnarray*}\]

Version: 25 April 2023