forked from joanby/r-basic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmedias.Rmd
More file actions
53 lines (33 loc) · 682 Bytes
/
medias.Rmd
File metadata and controls
53 lines (33 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
title: "Medias"
author: "JJ"
date: "12/7/2019"
output: html_document
---
# Medias
```{r}
x <- c(32,45,67,43,28,17,48,95)
n <- length(x)
```
Vamos a calcular las medias del vector `r x` que está formado por `r n` e observaciones
## Media aritmetica
$$\bar{x}= \frac{1}{n}\sum_{i=1}^n x_i$$
```{r}
sum(x)/n #mean()
```
# Media aritmética ponderada
$$\bar{x}_w = \frac{\sum_{i=1}^nw_i\cdot x_i}{\sum_{i=1}^nw_i}$$
```{r}
w <- c(1,2,2,3,3,2,2,1)
sum(w*x)/sum(w)
```
## Media geométrica
$$\bar{x}_g = \left(\prod_{i=1}^nx_i\right)^{1/n}$$
```{r}
prod(x)^(1/n)
```
## Media armónica
$$\bar{x}_a = \frac{n}{\sum_{i=1}^{n}\frac{1}{x_i}}$$
```{r}
n/sum(1/x)
```