<- function(x){sum(x)/length(x)} new_mean
http://tinyurl.com/4dfuycvt
Sample mean: \[ \overline{x} = \frac{1}{n}\sum^{n}_{i=1}x_{i} \]
Sample median: \[ median= \begin{cases} x_{(n+1)/2} &\text{if $n \equiv 1$} \\ \frac{(x_{n/2} + x_{((n/2)+1)})}{2} &\text{if $n \equiv 0$} \end{cases} \]
In R a freshly defined function:
new_median <- function(x) {
if(length(x) %% 2 != 0){
(sort(x)[length(x)/2] + sort(x)[(length(x)/2)+1])/2
} else{
sort(x)[ceiling(length(x)/2)]
}
}
%%
is called modulus. In this case, will return the remainder of the division (in this case by 2), and then will check if this value is different than 0. If so, then will apply the equation for the odd-numbered list.
Sample variance (unbiased): \[ S^{2} = \frac{1}{n-1}\sum^{n}_{i=1}(x_{i}-\overline{x})^{2} \]
Standard deviation
\[ S = \sqrt{\frac{1}{n-1}\sum^{n}_{i=1}(x_{i}-\overline{x})^{2}} \]
Variation coefficient
\[ CV = \frac{S}{\overline{x}} \times 100 \]
Estimates the range within which a population parameter is likely to fall. It provides a way to express the uncertainty or margin of error associated with a sample estimate. \[ \text{IC} = \bar{x} \pm Z \left( \frac{\sigma}{\sqrt{n}} \right) \]
Or if the population standard deviation of the population is unknown:
\[ \text{IC} = \bar{x} \pm t \left( \frac{s}{\sqrt{n}} \right) \]
dplyr
for summarizing statsWhere \(z = \frac{x - \mu} {\sigma}\) is the standardization function, the result is that \(\sigma = 1\) and \(\mu = 0\)
R
rnorm()
generates pseudorandom normal numbers.dnorm()
is the probability density function (PDF)pnorm()
is the cumulative density functionqnorm()
calculates the quantile of the normal distributionLet’s try with an example:
Now, the Adelie penguins display an average bill length of 38.8
mm and its standard variation is 2.6
mm. What’s the percentage of penguins of 40
mm or smaller?
[1] 0.6777938
When the frequencies of a random variable \(X\) cluster around a central value, it is said that it follows a normal distribution.
In summary a variable that appears to follow a normal distribution displays three properties:
BIOL2205 - IeI - Universidad de los Andes