# Retrieve 95% coverage of results from a hypergeometric distribution

7 messages
Open this post in threaded view
|

## Retrieve 95% coverage of results from a hypergeometric distribution

 This post was updated on . Suppose I have a urn containing 90 red and 10 black balls. Now I wanna remove 3 from the urn. By the following codes: m<-90;n<-10;k<-3; x<-0:3 dhyper(x,m,n,k) I can obtain the probability that 0,1,2,3 red balls will be removed.  0.000742115 0.025046382 0.247680891 0.726530612 So >95% time, 2 to 3 red balls will be removed and the resultant composition will be changed to 87:10 or 88:9, the original percent of red balls will be changed from 90 to 89.69 to 90.72 then. If now I have 50:50 and again to remove 3 balls, I will obtain the probability as: 0.1212 0.3788 0.3788 0.1212 To get the resultant range of red balls for >95% time, this time all the four cases have to consider and so the resultant change of red balls will become 48.45 to 51.54 So my problem is, is there any convenient built-in function that helps extract this 95% confidence interval-like data?
Open this post in threaded view
|

## Re: Retrieve hypergeometric results in large scale

 Perhaps you should read ?dhyper and if you have a hard time parsing that, then read ?Distributions and then go back to ?dhyper --------------------------------------------------------------------------- Jeff Newmiller                        The     .....       .....  Go Live... DCN:<[hidden email]>        Basics: ##.#.       ##.#.  Live Go...                                       Live:   OO#.. Dead: OO#..  Playing Research Engineer (Solar/Batteries            O.O#.       #.O#.  with /Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. jas4710 <[hidden email]> wrote: > >I'm going to use > >dhyper(x, m, n, k) > >to get a 95% coverage. Let me use an example to explain my problem: > >Suppose I have a urn containing 90 red and 10 black balls. >Now I wanna remove 3 from the urn. By the following codes: > >m<-90;n<-10;k<-3; >x<-0:3 >dhyper(x,m,n,k) > >I can obtain the probability that 0,1,2,3 red balls will be removed. > 0.000742115 0.025046382 0.247680891 0.726530612 > >So >95% time, 2 to 3 red balls will be removed and the resultant >composition >will be changed to >87:10 or 88:9, the original percent of red balls will be changed from >90 to >89.69 to 90.72 then. > >If now I have 50:50 and again to remove 3 balls, I will obtain the >probability as: >0.1212 0.3788 0.3788 0.1212 > >To get the resultant range of red balls for >95% time, this time all >the >four cases have to consider and so the resultant change of red balls >will >become 48.45 to 51.54 > >So my problem is, is there any convenient built-in function that helps >extract this 95% confidence interval-like data? > > > > > > >-- >View this message in context: >http://r.789695.n4.nabble.com/Retrieve-hypergeometric-results-in-large-scale-tp4644683.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-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Retrieve hypergeometric results in large scale

Open this post in threaded view
|

## Re: Retrieve hypergeometric results in large scale

 This post was updated on . In reply to this post by Jeff Newmiller Thanks Jeff~~~ In fact I do not know how to combine and extract vectors in R. ans<-sort(dhyper(x, m, n, k),decreasing=TRUE) rbind(ans,cumsum(ans) will show the first point that exceeds 95% threshold. The problem is: information is lostI can no longer identify where are the first few elements from. e.g. for 10 numbers, maybe they are from points 4,5,6,7; for 100 numbers, from points 45 to 68 How to append ID's to the data for later retrieval? rbind appears to do the job but not so exactly...
Open this post in threaded view
|

## Re: Retrieve hypergeometric results in large scale

 In reply to this post by Bert Gunter If you have not already done so, stop what you are doing and work through the Introduction to R tutorial that ships with R (or other R tutorial on the web that you may prefer). The tutorials are written to help you climb the R learning curve much more efficiently than the fooling around that you appear to be doing now. -- Bert On Mon, Oct 1, 2012 at 8:31 AM, jas4710 <[hidden email]> wrote: > Hi Bert. This is not a homework. If I can do some basic programming in R like > Perl, then I'll have a better chance to accomplish this task but the matrix > concept is not quickly comprehensible... > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Retrieve-95-coverage-of-results-from-a-hypergeometric-distribution-tp4644683p4644703.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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.