dimanche 30 mars 2014

Finding nearest value in a list


Vote count:

0




I have a list of percentiles and I wish to query a nearest value from it by specifying a probability and vice versa. Consider the following code:



samples <- runif(1000, 0, 1)
percentiles <- quantile(samples,probs=(0:100)/100)
plot(percentiles)


I can easily read the plot(e.g. 50% prob -> 0.5 in this example), however how can I find the nearest value in the list (either by specifying the probability or the value on the Y-axis) ?


Thanks!



asked 14 secs ago






Aucun commentaire:

Enregistrer un commentaire