[R] quantile of a discrete random variable

David Winsemius dwinsemius at comcast.net
Thu Jun 25 17:34:23 CEST 2015


On Jun 25, 2015, at 7:26 AM, L... L... wrote:

> Dear all, is there a general method for calculating the quantile of a discrete random variable? If yes, is there a R function to do this?

The `quantile` function would seem to be the first place to go. It may depend on the object-type of your representation of the "random variable".

?quantile                 # to see the help page

The default of type=7 may not be what you want, but I suspect one of the other types would be appropriate. You could also cobble something together along the lines of:

 list(x= as.numeric(names(table(x))), y=cumsum(table(x))/sum(x) )

Could use the result of ecdf(and then reversing x and y for evaluation.).

>    		  
> 	[[alternative HTML version deleted]]
This is a plain text mailing list
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list