John Wilkinson wrote:

On 08/24/04 13:50, Paolo Tommasini wrote:



Hi my name is Paolo Tommasini does anyone know how to compute a "mode"
( most frequent element ) for a distribution ?



try

median(density(my.vector))



That cannot be right. Try:

> test <- rnorm(1000)
> d <- density(test)
> median(d)
Error in median(d) : need numeric data
> str(d)
List of 7
$ x        : num [1:512] -3.64 -3.63 -3.62 -3.60 -3.59 ...
$ y        : num [1:512] 2.16e-05 2.60e-05 3.11e-05 3.71e-05 4.43e-05 ...
$ bw       : num 0.221
$ n        : int 1000
$ call     : language density(x = test)
$ data.name: chr "test"
$ has.na   : logi FALSE
- attr(*, "class")= chr "density"
> i <- which.max(d$y)
> d$x[i]
[1] 0.05625893


Kjetil halvorsen



John

John Wilknson

[EMAIL PROTECTED]

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html





______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to