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

Reply via email to