probla=:1-*/\1-(i.366)%366
   #probla
366  
   probrh=:1}.1-([: */ 366 %~ 366-i.)"0 i. 366
   #probrh
365

I modified an APL function I wrote almost 30 years ago and it matches what
you provided from Roger. I think an extra zero was introduced by the  i. of
in i.  

If I drop the first zero the first hundred of each match, but the two entire
lists are no longer the same length and do not match.

(1+i.25),.(i.25){probla
 1          0
 2 0.00273224
 3 0.00818179
 4  0.0163114
 5  0.0270621
 6  0.0403536
 7  0.0560856
 8  0.0741386
 9   0.094376
10   0.116645
11   0.140781
12   0.166604
13   0.193929
14    0.22256
15   0.252298
16   0.282941
17   0.314288
18   0.346138
19   0.378295
20    0.41057
21   0.442779
22   0.474751
23   0.506323
24   0.537346
25   0.567684
   
So, the simulations should be having a mean very near 23. I have to find the
extra  1  that I have introduced in my simaulations.

I'm anxious to tackle the "all at once" strategies.


Linda 

-----Original Message-----
From: programming-boun...@jsoftware.com
[mailto:programming-boun...@jsoftware.com] On Behalf Of Linda Alvord
Sent: Wednesday, January 18, 2012 9:12 AM
To: 'Programming forum'
Subject: Re: [Jprogramming] Challenge 4 Bountiful Birthdays

What we need is a traditional "proof", but this makes me suspicious that I
have some mistake in my strategy. I'll post what I have so far.

Linda

-----Original Message-----
From: programming-boun...@jsoftware.com
[mailto:programming-boun...@jsoftware.com] On Behalf Of Pablo Landherr
Sent: Wednesday, January 18, 2012 8:49 AM
To: Programming forum
Subject: Re: [Jprogramming] Challenge 4 Bountiful Birthdays

   b
[: -. [: */\@:-. [: %&365 i. NB. taking away the needless adjustment for
leap years
   (0, }:b 365) -:  -. ([: */ 365 %~ 365-i.)"0 i. 365 NB. comparing it to
Rogers solution in the J Wiki
1
   100 (6)!:2 'b 365'
2.17831e_5
   100 (6)!:2 '-. ([: */ 365 %~ 365-i.)"0 i. 365'
0.00222781


On Wed, Jan 18, 2012 at 2:15 PM, Pablo Landherr
<pablo.landh...@gmail.com>wrote:

> Another solution.
>
>    bdayprob
> [: -. [: */\@:-. [: %&365.25 i.
>    bdayprob 24
> 0 0.00273785 0.00819856 0.0163448 0.0271172 0.0404352 0.0561981 0.074286
> 0.0945617 0.116872 0.141051 0.166919 0.19429 0.222967 0.25275 0.283438
> 0.314827 0.346718 0.378912 0.411221 0.443461 0.475459 0.507053 0.538094
>
>
>
>
> On Wed, Jan 18, 2012 at 7:03 AM, Roger Hui
<rogerhui.can...@gmail.com>wrote:
>
>> Does http://www.jsoftware.com/jwiki/Essays/Birthday%20Problem answer any
>> of
>> your questions?
>>
>>
>>
>> On Tue, Jan 17, 2012 at 9:40 PM, Linda Alvord <lindaalv...@verizon.net
>> >wrote:
>>
>> >  Capture the last row of  c
>> >
>> >    ]l=:{:c
>> > 106 249 7 326 308 274 81 347 276 113 108 20...
>> >
>> > And use grade up to arrange the numbers in sequence
>> >
>> >   (/:l){l
>> > 0 1 3 3 4 4 5 5 6 6 7 7 7 7 8 8 8 13 13...
>> >
>> >   This should be  i.365
>> >
>> > I have an idea on how to get what you want but I'll wait to see what
>> you do
>> > next.
>> > I have to use a deal without a fixed seed for the deal.
>> >
>> > I happened to remember 24 and haven't gone looking for the number and
>> > haven't the foggiest notion of how I proved it!
>> >
>> > Linda
>> >
>> > -----Original Message-----
>> > From: Linda Alvord [mailto:lindaalv...@verizon.net]
>> > Sent: Tuesday, January 17, 2012 11:25 PM
>> > To: 'Programming forum'
>> > Subject: RE: [Jprogramming] Challenge 4 Bountiful Birthdays
>> >
>> > I think we need sortleaf.
>> >
>> > Linda
>> >
>> > -----Original Message-----
>> > From: programming-boun...@jsoftware.com
>> > [mailto:programming-boun...@jsoftware.com] On Behalf Of Brian Schott
>> > Sent: Tuesday, January 17, 2012 10:14 PM
>> > To: Programming forum
>> > Subject: Re: [Jprogramming] Challenge 4 Bountiful Birthdays
>> >
>> > $c=.500 365?.@$365
>> > $D=. i.&0"1(=&#~.)\"1 c
>> > mean D+1  NB. 25.086
>> > pretty 5 SL sortleaf 1+D
>> >
>> > $c=. 10 500 365?.@$365
>> > $D=. i.&0"1(=&#~.)\"1 c
>> > mean, D+1. NB. 24.6856
>> > pretty"2] 5 SL"0 1 sortleaf"1] 1+D
>> >
>> > I am suspicious of these results because my memory is that the mean is
>> > closer to 18.5 people. Then again, other measures of the center look
>> closer
>> > to 19, just looking at the stemplots.
>> >
>> > ---
>> > (B=)
>> >
>> > On Jan 15, 2012, at 5:40 AM, "Linda Alvord" <lindaalv...@verizon.net>
>> > wrote:
>> >
>> > >
>> > > For this challenge, as usual,  do not use  @  but you may use
whatever
>> > style
>> > > and strategy you like to accomplish the task.
>> > >
>> > >
>> > >
>> > > The problem is to simulate the classic birthday problem.
>> > >
>> > >
>> > >
>> > > A single trial works this way.  People enter a room one by one and
>> > declare
>> > > their birth date.  Suppose the 29th person is the first person to
>> match a
>> > > birthday of someone in the room.  The result of the first trial is
29.
>> > >
>> > >
>> > >
>> > > Repeat for 500 trials.
>> > >
>> > >
>> > >
>> > > If you use Kip's frequency distribution of the results you have lots
>> of
>> > > information.
>> > >
>> > >
>> > >
>> > >  fd=:[: /:~ ~. ,. [: +/"1 ~. =/ ]
>> > >
>> > >
>> > >
>> > > But the mean gives a more concise summary of the data.  So, the final
>> > part
>> > > of the problem is to obtain a list of  10  means of  500  trials and
>> the
>> > > mean of the means.
>> >
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to