Skip to content
Prev 176123 / 398503 Next

Problem with sample()

On 04/04/2009 6:34 PM, mackas21 wrote:
Presumably h doesn't contain a vector of positive probabilities.  You 
didn't give us a *minimal* reproducible example, but it is at least 
reproducible.  Using options(error=recover) breaks at the error, and at 
that point I see

Browse[1]> h
  [1]  9.555555556 -1.228399425 -0.161902016 -0.086878383 -0.058343015
  [6] -0.043116464 -0.033609194 -0.027105323 -0.022382548 -0.018806257
[11] -0.016012859 -0.013778429 -0.011957202 -0.010450045 -0.009187093
[16] -0.008117645 -0.007203985 -0.006417462 -0.005735913 -0.005141922
[21] -0.004621615 -0.004163804 -0.003759370 -0.003400807 -0.003081885
[26] -0.002797391 -0.002542934 -0.002314790 -0.002109784 -0.001925194
[31] -0.001758673 -0.001608193

so that's your problem.  I'll leave it up to you to figure out why h 
contains negatives.

Duncan Murdoch