The objectives of this homework assignment are the followings:
Note the following requirements:
In your repository, create a RMarkdown file called hw1.Rmd
providing an HTML output with the theme cerulean
and syntax highlighting tango
. This file should contain the following elements:
Sys.time()
)In order to do so, it is possible to simply write as a header to your RMarkdown:
---
title: "Homework 1"
author: Samuel Orso \& Iegor Rudnytskyi
date: "`r format(Sys.time(), '%d %B, %Y')`"
output: html_document:
theme: cerulean
highlight: tango
---
To create a section, use a single hash sign ("#"); to create a subsection, use a double hash sign ("##"). Here, one would write, for the introduction:
# Introduction
Here is the intro. Bla bla bla.
To add a video below, one would add the following nomenclature, for example for a Youtube video:
![](https://youtu.be/zNzZ1PfUDNk)
To do the above, one would for example have the following nomenclature, using LaTeX type format for the table:
# Group Members
## Samuel Orso
Lecturer in Data Science at UNIL,...
![An American logo](http://www.alumni.psu.edu/s/1218/16/images/logo.png)
My hobbies are...
>"Some mathematician, I believe, has said that true pleasure lies not in the discovery of truth, but in the search for it."
>-- Tolstoi
To create a table, one could for example use the kableExtra
package and write:
library(knitr)
library(kableExtra)
courses.taken <- c("Applied Mathematics", "Measure Theory", "R for Data Science")
time <- c("08:00", "08:00", "09:00")
df <- data.frame(cbind(courses.taken, time))
colnames(df) <- c("Courses taken", "Time")
kable_styling(kable(df, "html"))
cache = T
leads to a misleading answer. This example must be different from the one presented in the textbook.For example, this can be use to save some time while generating large random vectors. One example where cache=TRUE
can be misleading is when you first start by a chunk of the following form, specifying for the option:
set.seed(1)
a <- rexp(100)
and you call a
in another chunk, say the following one, with option cache=TRUE:
(b <- log(a))
without adding as option dependson=(name of the first chunk)
, since if you first knit with 100 randomly generated exponential numbers and you then change a
to rexp(1000)
, it will cache the value of a
and only show you b
accordingly.
runif()
. Store these 300 values in a vector called x
. Then, compute the empirical median, mean and variance of x
. Are these results different from 0, 0 and 1/3 (their respective theoretical values)? Is this result surprising? Justify your answer.Here is the code to do so:
set.seed(1)
x <- runif(n = 300, min = -1, max = 1)
empmean <- mean(x)
empmed <- median(x)
empvar <- var(x)
The values are somewhat different from 0, 0 and 1/3 respectively, not so much but this variation is due to the fact that we only compute sample estimates of population values for the values above. Therefore, there is a natural variation.
x
(make sure to include a caption to this figure). You can use the R function d <- denstiy()
with default parameters, and the plot(d)
function. Why does the estimated density exceed the [-1, 1] interval?One would use the following command:
d <- density(x)
plot(d, main = "Density")
adding as an option to this chunk the option fig.cap="Density estimation of x"
to display a caption to this figure.
By default density estimator uses “gaussian” kernel to construct the curve. Therefore, the points that are close to the borders (-1 and 1) add extra noise, which expands outside of the original interval. This noise may be reduced by decreasing the bandwidth bw
, as well as choosing a kernel with finite support, i.e. rectangular
or epanechnikov
.
\[
\begin{aligned}
\left( P^t f \right) ( \mathbf{x} ) =
f_b ( \mathbf{x} ) +
\frac{\sigma^2 t}{2 |D| d} \int_{\partial D}
\frac{\partial f}{\partial n} \mathrm{d} \widehat{\mathbf{y}} +
\sum c_m^0 \exp \left(
- \frac{\sigma^2 \widetilde{\kappa}_m^2 t}{2}
\right)
\widetilde{s}_m ( \mathbf{x} )
+ f_h ( \mathbf{x} )
\end{aligned}
\]
To do so, use the LaTeX nomenclature as follow:
$\hat{f}(\xi) = \frac{1}{\sqrt{2 \pi}} \int_{-\infty}^\infty f(x) \, e^{-i x \xi} \, \mathrm{d} x.$
Write:
<span style="color:green">"The degree of civilization in a society can be judged by entering its prisons.", Fyodor Dostoevsky text</span>
To do so, use:
<button data-toggle="collapse" data-target="#demo">More info</button>
<div id="demo" class="collapse">
Some additional info...
</div>
To do so, use:
<div class="alert alert-danger">
<strong>Some important Info:</strong> something
</div>