Create Artificial Binary Matrix based on probability

3 messages Options
Embed this post
Permalink
bikemike42

Create Artificial Binary Matrix based on probability

Reply Threaded More More options
Print post
Permalink
Dear All,

I am trying to create an artificial binary matrix such that each cell has a probability of 0.048 of having a 1.  So far the closest I've come is us by using a random poisson distribution with a mean of 0.048, but I can't figure out how to limit the max value to 1.  Otherwise that would work fine it seems.  Any suggestions?

The main code I've got to create said matrix so far is:
a<-replicate(26,rpois(57,0.048))

Thanks in Advance,
Mike
Erik Iverson-2

Re: Create Artificial Binary Matrix based on probability

Reply Threaded More More options
Print post
Permalink
Try
matrix(rbinom(100, 1, prob = 0.048), nrow = 10)



> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> On Behalf Of bikemike42
> Sent: Tuesday, November 03, 2009 11:49 AM
> To: [hidden email]
> Subject: [R] Create Artificial Binary Matrix based on probability
>
>
> Dear All,
>
> I am trying to create an artificial binary matrix such that each cell has
> a
> probability of 0.048 of having a 1.  So far the closest I've come is us by
> using a random poisson distribution with a mean of 0.048, but I can't
> figure
> out how to limit the max value to 1.  Otherwise that would work fine it
> seems.  Any suggestions?
>
> The main code I've got to create said matrix so far is:
> a<-replicate(26,rpois(57,0.048))
>
> Thanks in Advance,
> Mike
> --
> View this message in context: http://old.nabble.com/Create-Artificial-
> Binary-Matrix-based-on-probability-tp26160622p26160622.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> 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.

______________________________________________
[hidden email] mailing list
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.
bikemike42

Re: Create Artificial Binary Matrix based on probability

Reply Threaded More More options
Print post
Permalink
Thanks a lot Erik and Tony!
Both of your suggestions accomplish what I need.
Cheers,
Mike

Erik Iverson wrote:

> Try
> matrix(rbinom(100, 1, prob = 0.048), nrow = 10)
>
>
>
>  
>> -----Original Message-----
>> From: [hidden email] [mailto:[hidden email]]
>> On Behalf Of bikemike42
>> Sent: Tuesday, November 03, 2009 11:49 AM
>> To: [hidden email]
>> Subject: [R] Create Artificial Binary Matrix based on probability
>>
>>
>> Dear All,
>>
>> I am trying to create an artificial binary matrix such that each cell has
>> a
>> probability of 0.048 of having a 1.  So far the closest I've come is us by
>> using a random poisson distribution with a mean of 0.048, but I can't
>> figure
>> out how to limit the max value to 1.  Otherwise that would work fine it
>> seems.  Any suggestions?
>>
>> The main code I've got to create said matrix so far is:
>> a<-replicate(26,rpois(57,0.048))
>>
>> Thanks in Advance,
>> Mike
>> --
>> View this message in context: http://old.nabble.com/Create-Artificial-
>> Binary-Matrix-based-on-probability-tp26160622p26160622.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> [hidden email] mailing list
>> 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.
>>    
>
>  

--
Michael L. Treglia
Graduate Student
Wildlife and Fisheries Sciences
Texas A&M University
Lab: (979)862-7245
Cell: (917)841-5603
[hidden email]
http://people.tamu.edu/~mlt35

______________________________________________
[hidden email] mailing list
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.