search for: rbinom

Displaying 20 results from an estimated 461 matches for "rbinom".

Did you mean: dbinom
2000 Feb 17
2
bug in rbinom? (PR#448)
...m R. # Please copy the bug report (after finishing it) to # your favorite email program and send it to # # r-bugs@biostat.ku.dk # ###################################################### In version 0.99.0 for Windows NT I get the following: > .Random.seed [1] 0 21012 4461 28299 > rbinom(10,10,.3) [1] 4 5 5 1 5 2 4 2 6 2 > rbinom(10,9,.3) [1] 0 0 0 0 0 0 0 0 0 0 > rbinom(10,10,.3) [1] 3 3 2 2 3 1 3 3 3 2 > rbinom(10,11,.3) [1] 0 0 0 0 0 0 0 0 0 0 I tried similar inputs in version 0.65.1: > .Random.seed [1] 0 16049 70 30225 > rbinom(10,10,.3) [1] 3 5 3...
2012 Jan 04
5
a quick question about "rbinom"
Hello, I have the following code using rbinom, but I don't understand what *"+1"* means in the code. Could someone help? Thanks so much, > X1<-c("A","B")[rbinom(n,1,0.6)+1] > X2<-c("C","D")[rbinom(n,1,0.1)+1] -- View this message in context: http://r.789695.n4.nabble.com/a-qui...
2012 Jun 18
6
Trying to speed up an if/else statement in simulations
...n flag2 should be 1 with probability 0.95 and zero otherwise Else if flag1=0 then flag2 should be 1 with probability 0.5 and zero otherwise I can set up this example quite simply using if else statements, but this is incredibly inefficient when running thousands of datasets: data<-as.data.frame(rbinom(10,1,0.5)) colnames(data)<-'flag1' for (i in 1:n) { if (data$flag1[i]==1) {data$flag2[i]<-rbinom(1,1,0.95)} else {data$flag2[i]<-rbinom(1,1,0.5)} } I think to speed up the simulations I would be better changing to vectorisation and using something like: ifelse(data$flag1==1,...
2005 Apr 02
2
Solaris10/amd64 + SunSutio Compile (PR#7767)
Full_Name: Teru KAMOGASHRIA Version: 2.0.1 OS: SunOS sun 5.10 Generic i86pc i386 i86pc Submission from: (NULL) (219.5.176.24) rbinom.c cannot be compiled because of the casting problem. /opt/SUNWspro/bin/cc -I. -I../../src/include -I../../src/include -I/usr/local/include -DHAVE_CONFIG_H -D__NO_MATH_INLINES -g -c rbinom.c -o rbinom.o "rbinom.c", line 60: operand must have real floating type: op "isfinite" cc...
2010 Jun 23
1
Generation of binomial numbers using a loop
Dea'R' helpers I have following data - prob = c(0.1, 0.2, 0.3, 0.4, 0.5) frequency = c(100, 75, 45, 30, 25) no_trials = c(10, 8, 6, 4, 2) freq1 = rbinom(frequency[1], no_trials[1], prob[1]) freq2 = rbinom(frequency[2], no_trials[2], prob[2]) freq3 = rbinom(frequency[3], no_trials[3], prob[3]) freq4 = rbinom(frequency[4], no_trials[4], prob[4]) freq5 = rbinom(frequency[5], no_trials[5], prob[5]) total_frequency = c(freq1, freq2, freq3, freq4, freq5...
2005 Aug 16
2
quirky behavior from rbinom (PR#8071)
Full_Name: Chris Paulse Version: 2.1.1 OS: WinXP Submission from: (NULL) (129.98.60.134) This seems strange. I have a small block of code that repeatedly calls rbinom. I put a break in there in case it returns NaN, as I've been having problems with this. Here is a transcript from the debug session: Browse[1]> theP [1] 1 Browse[1]> yleft[dataIndex] [1] 3 Browse[1]> rbinom(1,3,1) [1] 3 Browse[1]> rbinom(1,yleft[dataIndex], theP) [1] NaN Strange...
2006 Sep 20
1
Simulation help
I'm trying to simulate trend data over a five year period. I want different trend profiles...the simplest being a linear trend. I've been using the following code: patBdta1 <- NULL for(i in 1:100) patBdta1 <- rbind(patBdta1,c(yr1= mean(rbinom(50,1,.50)), yr2 =mean(rbinom(50,1,.51)), yr3 =mean(rbinom(50,1,.52)), yr4 =mean(rbinom(50,1,.53)), yr5 =mean(rbinom(50,1,.54)))) This code creates 100 data sets each with a 5...
2008 Jul 09
3
rbinom for a matrix
I have a large matrix full of probabilities; I would like to convert each probability to a 1 or a 0 using rbinom. How can I do this on the entire matrix? The matrix was converted from a raster ArcMap dataset, so the matrix is essentially a map. Because of this, I have no column headings. Thanks! -- View this message in context: http://www.nabble.com/rbinom-for-a-matrix-tp18366867p18366867.html Sent from the...
2001 Dec 02
1
bug in rbinom? (PR#1190)
Full_Name: Kert Viele Version: 1.3 OS: Windows ME and 2000 Submission from: (NULL) (65.6.218.65) Hello! Thanks for all your efforts on R. They are appreciated! I was simulating the central limit theorem in class, but found that repeated use of mean(rbinom(100000,500,0.4)) resulted in values less than 200 (the expected mean), for example > mean(rbinom(100000,500,0.4)) [1] 199.0294 > mean(rbinom(100000,500,0.4)) [1] 199.1077 > mean(rbinom(100000,500,0.4)) [1] 199.0668 and so on. I did this 1000 times and found the results to be distributed...
2023 Apr 08
1
Error message for infinite probability parameters in rbinom() and rmultinom()
...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 > rgeom(1...
2007 Oct 17
3
how to repeat the results of a generated probabilities
...ilities that I calculate from the marginal prob. (z1 and z2 respectively) multiple by the conditional prob. (x1 and x2 respectively), which I generaterd from the binomial distribution. here are the results for one mean of y1 and one mean of y2: > y1 <- 0 > for (i in 1:200){ + z1[i] <- rbinom(1, 1, .6) + x1[i] <- rbinom(1, 1, .95) + y1[i] <- z1[i]*x1[i] + } > mean(y1) [1] 0.605 > y2 <- 0 > for (j in 1:200){ + z2[j] <- rbinom(1, 1, .6) + x2[j] <- rbinom(1, 1, .8) + y2[j] <- z2[j]*x2[j] + } > mean(y2) [1] 0.515 > and this I want to simulate 200 time, in or...
2010 Feb 17
1
lapply to apply a function using a vector
Hi, First, thank you all for your help. Here is my problem (simplified): Say I have a list: a=list(matrix(50,nrow=5,ncol=5),matrix(25,nrow=5,ncol=5),matrix(10,nrow=5,ncol=5)) I'd like to use rbinom with a different probability for each matrix. I tried: b=c(.8,.1,.9) brep=rep(b,each=25) lapply(a,function(a) rbinom(25,a,brep)) but that doesn't work-- it just uses the first value of b rather than applying it over that list. what I am currently doing is: c=list() for (i in 1:3){c[[i]]=rbino...
2023 Apr 08
1
Error message for infinite probability parameters in rbinom() and rmultinom()
...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 > >>...
2008 Sep 09
2
naive variance in GEE
Hi, The standard error from logistic regression is slightly different from the naive SE from GEE under independence working correlation structure. Shouldn't they be identical? Anyone has insight about this? Thanks, Qiong a<-rbinom(1000,1) b<-rbinom(1000,2,0.1) c<-rbinom(1000,10,0.5) summary(gee(a~b, id=c,family="binomial",corstr="independence"))$coef summary(glm(a~b,family="binomial"))
2023 Apr 08
1
Error message for infinite probability parameters in rbinom() and rmultinom()
...mit (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 > Wa...
2011 Dec 14
0
hclust and ggplot2
...get an error when trying to use ggplot; Error: ggplot2 doesn't know how to deal with data of class phylo. Regular plot works fine but I can't get ggplot2 to work. see code below.... rows=100 columns=100 #create matrix all=matrix(nrow=rows, ncol=columns) #initialize first column all[,1]=rbinom(rows,1,.5) #set probability probv=.9 for (j in 2:columns) { for (i in 1:rows) { #set the probability based on the values in the columns to the left if (all[i,j-1]==1) {all[i,j]=rbinom(1,1,1-probv)} else {all[i,j]=rbinom(1,1,probv)} } } #make...
2008 May 28
5
"rbinom" not using probability of success right
I am trying to simulate a series of ones and zeros (1 or 0) and I am using "rbinom" but realizing that the number of successes expected is not accurate. Any advice out there. This is the example: N<-500 status<-rbinom(N, 1, prob = 0.15) count<-sum(status) 15 percent of 500 should be 75 but what I obtain from the "count" variable is 77 that gives the pro...
2012 Jan 03
1
nls and rbinom function: step factor 0.000488281 reduced below 'minFactor' of 0.000976562
I  am trying to learn nls using a simple simulation. I assumed that the binomial prob varies linearly as 0.2 + 0.3*x in  x {0,1}, and the objective is to recover the known parameters a=0.2, b=0.3 ..data frame d has 1000 rows... d$x<-runif(0,1)               d$y<-rbinom(1000,1,0.2+0.3*d$x)  table(d$y,cut(d$x,breaks=5));   (-0.000585,0.199] (0.199,0.399] (0.399,0.599] (0.599,0.799] (0.799,0.999]   0               154           149           130           122           114   1                34            48            71            76           102  z <- nls(...
2014 Jan 15
1
rbinom in RcppArmadillo?
What is the RcppArmadillo way to make binomial draws from a vector of probs, similar to what rbinom does in R? Thanx! -- View this message in context: http://r.789695.n4.nabble.com/rbinom-in-RcppArmadillo-tp4683593.html Sent from the R devel mailing list archive at Nabble.com.
2006 Jun 29
1
using "rbinom" in C code gives me erroneous results... random variable is not random (always zero)...
Dear Listers, I am trying to use "rbinom" in my C code, but i always get zeros as output no matter the probability. Am not sure what I am doing wrong because the function has worked before. Attached in an example. Noticed that "rbinom" expects 'n' to be REAL. Regards, Vumani R 2.3.1 (2006-06-01) Windows XP Gcc /*...