On Oct 23, 4:54 pm, Patrick <patrick.mat...@gmx.ch> wrote:
> Dan, Eric
> Thanks to both of you.
> Got it now.
> This piece of code is really a beauty.
What coincidence! I was covering the same topic today afternoon!
One way the code could be understood is by assuming that
"sampsize=totobs" and mentally working out to how the code would
perform. You would note that the If condition would always be true and
so on. Then modify it to other extreme with "sampsize=1" and it starts
to again make sense as to why the code would work.
Also one can never get less than the required Sampsize because even if
"large number of initial observations are rejected" then at some point
sampsize would then become equal to obsleft and so the if condition
would turn true, making it accept all the rest observations.
On the mathematics -- A few years back I had been very surprised when
I first saw the statement similar to (probability of picking 2 black
balls from a urn having a mixture of 3 Black and 2 Red with
replacement is same as the probability of picking without replacement)
in one of the book for prob/stats (not able to recollect author's name
~ Washington State univ). In order to convince myself working out the
proof (similar to John W) was the first step.
But the algebra didnt really cool my heart and mind. I subsequently
"fabricated" an non-algebraic but a "logical" explanation as to why
this property holds. In case of Without replacement --> the first item/
ball which is picked up can be theoretically considered to be a
"composite" ball having 60% black ball characteristics and 40% red
ball characteristics. Now, when we look back in our Urn, the
proportion of black and red ball characteristics havent changed
because we now have 2.4 black balls and 1.6 red balls. From this
probability of picking a new black ball is 2.4/(2.4+1.6) which is
Not sure if the above pseudo logic works for anybody else.