Description Usage Arguments Details Value Note See Also Examples

Geometric and harmonic mean along a dimension of a vector, matrix, or
array.

`trimmean`

is almost the same as `mean`

in R.

1 2 3 4 |

`x` |
numeric vector, matrix, or array. |

`dim` |
dimension along which to take the mean; |

`percent` |
percentage, between 0 and 100, of trimmed values. |

`trimmean`

does not call `mean`

with the `trim`

option, but
rather calculates `k<-round(n*percent/100/2)`

and leaves out `k`

values at the beginning and end of the sorted `x`

vector (or row or
column of a matrix).

Returns a scalar or vector (or array) of geometric or harmonic means:
For `dim=1`

the mean of columns, `dim=2`

the mean of rows, etc.

To have an exact analogue of `mean(x)`

in Matlab,
apply `trimmean(x)`

.

1 2 3 4 5 6 7 8 9 10 | ```
A <- matrix(1:12, 3, 4)
geomean(A, dim = 1)
## [1] 1.817121 4.932424 7.958114 10.969613
harmmean(A, dim = 2)
## [1] 2.679426 4.367246 5.760000
x <- c(-0.98, -0.90, -0.68, -0.61, -0.61, -0.38, -0.37, -0.32, -0.20, -0.16,
0.00, 0.05, 0.12, 0.30, 0.44, 0.77, 1.37, 1.64, 1.72, 2.80)
trimmean(x); trimmean(x, 20) # 0.2 0.085
mean(x); mean(x, 0.10) # 0.2 0.085
``` |

pracma documentation built on Jan. 30, 2018, 3:01 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.