search for: rgeom

Displaying 20 results from an estimated 48 matches for "rgeom".

Did you mean: geom
2000 May 12
1
Geometric Distribution at prob=c(0,1)
...ion for the time being, and I''m confused. This may have more to do with statistics than R itself, but since I''m getting results from R I find counterintuitive (well, yeah, my statistical intuition has not been properly sharpened), I feel like asking. The point first: If I do > rgeom(1,prob=1) I get: [1] NaN Warning message: NAs produced in: rgeom(n, prob) And if I do: > rgeom(1,prob=0) I get: [1] NaN Warning message: NAs produced in: rgeom(n, prob) I was expecting to get 0 and Inf respectively.... Should I expect that? Going back to my textbooks (Dudewicz and Mishra 1...
2023 Apr 08
1
Error message for infinite probability parameters in rbinom() and rmultinom()
.... Maybe, a more precise message will be helpful when debugging. > rmultinom(1, 3:5, c(1/2, 1/3, Inf)) Error in rmultinom(1, 3:5, c(1/2, 1/3, Inf)) : NA in probability vector > rmultinom(1, 3:5, c(1/2, 1/3, NA)) Error in rmultinom(1, 3:5, c(1/2, 1/3, NA)) : NA in probability vector For rgeom() or rbinom(), we got a warning for infinite probability : > rbinom(1, 3, Inf) [1] NA Warning message: In rbinom(1, 3, Inf) : NAs produced > rbinom(1, 3, NA) [1] NA Warning message: In rbinom(1, 3, NA) : NAs produced > rgeom(1, Inf) [1] NA Warning message: In rgeom(1, Inf) : NAs produced...
2015 Mar 24
0
Faster version of rgeom()
Hi, I recently took a closer look at the implementations of sampling algorithms for all basic distributions in R. Two seemed inefficient (slow) to me: 1) rgeom() 2) rexp() Obviously, Geo(p) and Exp(lambda) have very simple stochastic representations (floor(Y) for Y ~ Exp(-log(1-p)) and (-log U)/lambda for U ~ U[0,1]). I thought I could easily beat the (more complicated) algorithms that R uses for these two distributions. Even Ahrens and Dieter (1972) (the...
2023 Apr 08
1
Error message for infinite probability parameters in rbinom() and rmultinom()
...e as the limit (of a sequence) of (a) very large number(s). I claim that rmultinom(1, 3, c(1/2, 1/3, Inf)) should give the same as rmultinom(1, 3, c(1/2, 1/3, 1e300)) even without a warning, and OTOH, an NA in prob may return NA (and signal a warning) instead of an error. > For rgeom() or rbinom(), we got a warning for infinite probability : Yes, but there, prob must be in [0,1] ... so that's somewhat differnt. >> rbinom(1, 3, Inf) > [1] NA > Warning message: > In rbinom(1, 3, Inf) : NAs produced >> rbinom(1, 3, NA) > [1] NA...
2023 Apr 08
1
Error message for infinite probability parameters in rbinom() and rmultinom()
...wer because we don't know the relative size of the two infinities. I imagine the first NA comes from computing prob/sum(prob), which is c(0, 0, NaN). Duncan Murdoch > and OTOH, an NA in prob may return NA (and signal a warning) > instead of an error. > > > > For rgeom() or rbinom(), we got a warning for infinite probability : > > Yes, but there, prob must be in [0,1] ... so that's somewhat differnt. > > >> rbinom(1, 3, Inf) > > [1] NA > > Warning message: > > In rbinom(1, 3, Inf) : NAs produced >...
2020 Jan 20
3
[External] Re: rpois(9, 1e10)
...double := double" - as 'long double' > unfortunately is not well defined by C standards) > > Martin > Martin if you are in favor, then certainly no objection from me! ;-) So now what about other discrete distributions e.g. could a similar enhancement apply here? > rgeom(10L, 1e-10) ?[1]???????? NA 1503061294???????? NA???????? NA 1122447583???????? NA ?[7]???????? NA???????? NA???????? NA???????? NA Warning message: In rgeom(10L, 1e-10) : NAs produced
2020 Jan 20
3
[External] Re: rpois(9, 1e10)
...; >> > >> Martin > >> > > Martin if you are in favor, then certainly no objection from me! ;-) > > > So now what about other discrete distributions e.g. could a similar > > enhancement apply here? > > > >> rgeom(10L, 1e-10) > > ?[1]???????? NA 1503061294???????? NA???????? NA 1122447583???????? NA > > ?[7]???????? NA???????? NA???????? NA???????? NA > > Warning message: > > In rgeom(10L, 1e-10) : NAs produced > > yes, of course there are several such distribut...
2020 Jan 22
2
[External] Re: rpois(9, 1e10)
...>> > Martin if you are in favor, then certainly no objection from me! ;-) >>> >>> > So now what about other discrete distributions e.g. could a similar >>> > enhancement apply here? >>> >>> >>> >> rgeom(10L, 1e-10) >>> > ?[1]???????? NA 1503061294???????? NA???????? NA 1122447583???????? NA >>> > ?[7]???????? NA???????? NA???????? NA???????? NA >>> > Warning message: >>> > In rgeom(10L, 1e-10) : NAs produced >>> >...
2020 Jan 20
0
[External] Re: rpois(9, 1e10)
...ortunately is not well defined by C standards) >> >> Martin >> > Martin if you are in favor, then certainly no objection from me! ;-) > So now what about other discrete distributions e.g. could a similar > enhancement apply here? >> rgeom(10L, 1e-10) > ?[1]???????? NA 1503061294???????? NA???????? NA 1122447583???????? NA > ?[7]???????? NA???????? NA???????? NA???????? NA > Warning message: > In rgeom(10L, 1e-10) : NAs produced yes, of course there are several such distributions. It's really somethi...
2008 Mar 16
2
(no subject)
Hi, I am trying to use the Fisher scoring method with a geometric distribution, with p = .07, 100 observations from the geom distrib, and 10 iterations. I cannot quite get the code to work. Can anyone see the mistake? n <- 100 p <- 0.07 x <- rgeom(n, p) s <- sum(x) f <- function(x, p) p*(1-p)^x L <- function(p) p^n*(1-p)^s logL <- function(p) n*log(p)+s*(log(1-p)) logLprime <- function(p) (n/p)-(s/(1-p)) I <- n/p^2*(1-p) iter <- 10 p[1] <- .06 p[2] <- .11 for (i in 1:10) { pn...
2020 Jan 21
0
[External] Re: rpois(9, 1e10)
...>> >> >> > Martin if you are in favor, then certainly no objection from me! ;-) >> >> > So now what about other discrete distributions e.g. could a similar >> > enhancement apply here? >> >> >> >> rgeom(10L, 1e-10) >> > ?[1]???????? NA 1503061294???????? NA???????? NA 1122447583???????? NA >> > ?[7]???????? NA???????? NA???????? NA???????? NA >> > Warning message: >> > In rgeom(10L, 1e-10) : NAs produced >> >> yes, of course...
2020 Jan 22
0
[External] Re: rpois(9, 1e10)
...in favor, then certainly no objection from me! ;-) > >>> > >>> > So now what about other discrete distributions e.g. could a similar > >>> > enhancement apply here? > >>> > >>> > >>> >> rgeom(10L, 1e-10) > >>> > ?[1]???????? NA 1503061294???????? NA???????? NA 1122447583???????? NA > >>> > ?[7]???????? NA???????? NA???????? NA???????? NA > >>> > Warning message: > >>> > In rgeom(10L, 1e-10) : NAs produced &g...
1997 Jul 09
1
R-beta: Problem with `rpois'
There is a problem with `rpois'. It does seem to take care about the order of the arguments. This is an example: > rpois(n=1,lambda=2) [1] 3 > rpois(lambda=2,n=1) [1] 2 0 It obviously uses the first argument as the number of samples to be drawn, which is wrong. I used Version 0.49 Beta (April 23, 1997). Fredrik
1997 Jul 09
1
R-beta: Problem with `rpois'
There is a problem with `rpois'. It does seem to take care about the order of the arguments. This is an example: > rpois(n=1,lambda=2) [1] 3 > rpois(lambda=2,n=1) [1] 2 0 It obviously uses the first argument as the number of samples to be drawn, which is wrong. I used Version 0.49 Beta (April 23, 1997). Fredrik
2011 Apr 28
3
Simple General Statistics and R question (with 3 line example) - get z value from pairwise.wilcox.test
Hi there, I am trying to do multiple pairwise Wilcoxon signed rank tests in a manner similar to: a <- c(runif(1000, min=1,max=50), rnorm(1000, 50), rnorm(1000, 49.9, 0.5), rgeom(1000, 0.5)) b <- c(rep("group_a", 1000), rep("group_b", 1000), rep("group_c", 1000), rep("group_d", 1000)) pairwise.wilcox.test(a, b, alternative="two.sided", p.adj="bonferroni", exact=F, paired=T) This gives me the following output:...
2008 Dec 16
1
simulate binary markov chain
Hi all, I was hoping somebody may know of a function for simulating a large binary sequence (length >10 million) using a (1st order) markov model with known (2x2) transition matrix. It needs to be reasonably fast. I have tried the following; mc<-function(sq,P){ s<-c() x<-row.names(P) n<-length(sq) p1<-sum(sq)/n s[1] <- rbinom(1,1,p1); for ( i in 2:n){ s[i]
2020 Jan 23
1
[External] Re: rpois(9, 1e10)
On 1/20/20 12:33 PM, Martin Maechler wrote: > > It's really something that should be discussed (possibly not > here, .. but then I've started it here ...). > > The NEWS for R 3.0.0 contain (in NEW FEATURES) : > > * Functions rbinom(), rgeom(), rhyper(), rpois(), rnbinom(), > rsignrank() and rwilcox() now return integer (not double) > vectors. This halves the storage requirements for large > simulations. > > and what I've been suggesting is to revert this change > (svn rev r60225-6) which was...
2008 Jul 31
5
Random number generation
Hi Everyone, I did a quick search of the list and it looks like this may not have been asked before... I'm trying to generate a matrix of random numbers between 0 and 1, with 6 columns, 10000 rows. About all I know is that runif(1) gives me the random number I'm looking for. Any help would be great! thanks, -Max
2008 Jul 31
5
Random number generation
Hi Everyone, I did a quick search of the list and it looks like this may not have been asked before... I'm trying to generate a matrix of random numbers between 0 and 1, with 6 columns, 10000 rows. About all I know is that runif(1) gives me the random number I'm looking for. Any help would be great! thanks, -Max
2009 Mar 17
3
R does not compile any more on FreeBSD 8.0-CURRENT
...pnorm.o qnorm.o rnorm.o dlnorm.o plnorm.o qlnorm.o rlnorm.o df.o pf.o qf.o rf.o dnf.o dt.o pt.o qt.o rt.o dnt.o dchisq.o pchisq.o qchisq.o rchisq.o rnchisq.o dbinom.o pbinom.o qbinom.o rbinom.o rmultinom.o dcauchy.o pcauchy.o qcauchy.o rcauchy.o dexp.o pexp.o qexp.o rexp.o dgeom.o pgeom.o qgeom.o rgeom.o dhyper.o phyper.o qhyper.o rhyper.o dnbinom.o pnbinom.o qnbinom.o rnbinom.o dpois.o ppois.o qpois.o rpois.o dweibull.o pweibull.o qweibull.o rweibull.o dlogis.o plogis.o qlogis.o rlogis.o dnchisq.o pnchisq.o qnchisq.o dnbeta.o pnbeta.o qnbeta.o pnf.o pnt.o qnf.o qnt.o ptukey.o qtukey.o toms708...