Roul, Your expression is a good one. To define a verb you could start here:
(~.,.#/.~)/:~+/1+?2 1e6$6 2 28046 3 55258 4 83532 5 111206 6 138742 7 166167 8 139145 9 111078 10 83270 11 55635 12 27921 Now define a function. It could easily be monadic: fdrm=: 13 :'(~.,.#/.~)/:~+/1+?y' fdrm [: (~. ,. #/.~) [: /:~ [: +/ 1 + ? ]d=:fdrm 2 1e6$6 2 27744 3 55994 4 83221 5 111031 6 138908 7 166726 8 138794 9 111511 10 82566 11 55995 12 27510 There is only one more design issue and we'll be finished with the turkey roll. Finally define a function to produce the percentage of each of the rolls occurred. Percent was traumatic for some students, so we'll give the function a warm fuzzy name: purr=: purr (your tacit definition should land here) Now see what happens to your data: purr d 2 0.027797 3 0.05549 4 0.082886 5 0.111182 6 0.138412 7 0.166141 8 0.140112 9 0.11171 10 0.083511 11 0.055302 12 0.027457 assert 1=1{+/purr d Put in your function and data (purr d) and no response indicates the sum of the percentages in the second column had a sum of 1 or 100% Now see if you can write purr. Linda -----Original Message----- From: programming-boun...@jsoftware.com [mailto:programming-boun...@jsoftware.com] On Behalf Of Raul Miller Sent: Monday, December 05, 2011 10:03 AM To: Programming forum Subject: Re: [Jprogramming] Many Turkey Rolls - No embargo I am having trouble understanding this one also. I think I understand 1: #/.~/:~+/?2 1e6$6 27773 55724 83930 111049 138508 166122 138982 111263 83609 55632 27408 Or, perhaps: (~.,.#/.~)/:~+/1+?2 1e6$6 2 27704 3 55158 4 83565 5 111238 6 138938 7 167140 8 138898 9 110833 10 83313 11 55783 12 27430 Item 2, however, seems mysterious. The platonic solids would have face counts of 4, 6, 8, 12, 20, but if we had 100 of each in a bucket and toss the bucket 200 times and total the numbers we will almost always have over 100 unique values in those resulting sums. This would result in a rather odd frequency distribution so I'm not at all sure that I understand the problem correctly. Furthermore, the additional text seemed to have little relation to these two items, so I am very confused. -- Raul On Sun, Dec 4, 2011 at 6:12 PM, Linda Alvord <lindaalv...@verizon.net>wrote: > Below you will find my version with some changes. However, I've pointed > out > some other versions that were superior to mine. When I tried to mix them I > got all mixed up. To do these two exercises, you may use any of the > statements below. Modify their use to: > > 1. Toss a pair of dice a million times and produce a frequency > distribution of the sums. This a simulation and there will be no graphic > images of the results. > > 2. Image a large bucket with 100 dice of each of the five Platonic > Solids. Each die is numbered from 1 with consecutive counting numbers. > Simulate the result and summarize your results in a frequency distribution > of the dice are all tosses from the bucket 200 times. > > > > Here are the expression you may choose from along with J symbols. Make > your > expressions as simple as possible. (I think Ric, Kip and Henry should just > watch and maybe referee if needed.) > > > > > > d1=:' o ' > > d2=:'o o' > > d3=:'o o o' > > d4=:'o o o o' > > d5=:'o o o o o' > > d6=:'o oo oo o' > > d=:6 9$d1,d2,d3,d4,d5,d6 > > dice=:(<"2)3 3$"1 d > > dice > > s=: 13 :'c=:1+?2 10$y' > > toss=: 13 :'(<"2)3 3$"1(<:s y){d' > > c > > toss 6 > > c > > toss=: 13 :'(<"2)3 3$"1(<:s y){d' > > t=: 13 :'+/"2 y' > > fd=: [: /:~ ~. ,. [: +/"1 = > > dice > > toss 6 > > c > > t c > > fd t c > > toss 6 > > c > > t c > > fd t c > > toss 4 > > c > > t c > > fd t c > > assert 0 0 3 3 3 3 = 4!:0 ;:'dice c s t toss fd' > > > > NB. dice is a graphic image of the faces of a die > > NB. c captures the data from an array of random rolls of the dice > > NB. s is the shape and s y allows for different dice > > NB. t is a list of totals for each of the tosses > > NB. fd is a frequency distribution of data in a list > > > > > > > ---------------------------------------------------------------------- > 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