Yes, you need to come up with an index which separates democrats from
republicans.
Kosuke
On Tue, 11 Feb 2003, John Bright wrote:
Yongwook,
Your sequence "pool" is a list of 100 elements, with values from 1 to 100. I
think you want to change the values in your sequence so that the number of
elements that take on the value "1" corresponds to the number of democrats,
and the rest of the elements (which represent republicans) take on the value
"0" (or some other values that will distinguish between the two).
Your if statement tests if the length of the unique sample is less than 5.
As you have your sampling done now, the sample contains all unique numbers,
so you will never get less than 5 unique numbers from your sample (without
replacement). After you make the changes above you will still want to change
your if statement. You want to record the times that all of the people drawn
from the senate are democrats, or in terms of the above coding convention
(dems = 1), you want to record when your sample contains all 1's.
Hope this help.
John.
On 2/11/03 2:25 AM, "Yongwook Ryu" <yryu(a)fas.harvard.edu> wrote:
all,
I wrote the following function for Q1(a), and got the obviously wrong answer.
any idea as to what I did wrong?
sims<-1000
people<-5
pool<-seq(1,100,1)
same<-0
for(i in 1:sims){
+ comm<-sample(pool, people, replace=FALSE)
+ if(length(unique(comm))<people)
+ same<-same+1}
cat("probability of =5 people being in the
same committee:", same/sims, "\n")
probability of >=5 people
being in the same committee: 0
yongwook
-----------------------------
Yongwook Ryu
PhD Candidate
Department of Government
Harvard University
Tel:617-493-3397
Email: yryu(a)fas.harvard.edu
-----------------------------
_______________________________________________
gov2001-l mailing list
gov2001-l(a)fas.harvard.edu
http://www.fas.harvard.edu/mailman/listinfo/gov2001-l
_______________________________________________
gov2001-l mailing list
gov2001-l(a)fas.harvard.edu
http://www.fas.harvard.edu/mailman/listinfo/gov2001-l