Raul,
I ran your code and cut and pasted it in this message. I'm not sure how it
will look. Try to ignore all the linefeeds and focus more on the results.
Here are some of my thoughts.
You made it all the way to a frequency distribution which meets the
requirements. That is a good first step. Actually you are the first to submit a
result that gets that far.
My most serious suggestion relates to the fact that you are missing the major
idea in creating a verb. You need to study how to write explicit verbs in one
line. As you change the arguments you will get different results without
changing the verb.
In a frequency distribution, usually the left column is arranged in numeric
order. It is usally, although not always, arranged from small to large.
You have gotten your results in some sort of random order. Using sort you
will be able to change that. After that it should be easy to create purr or a
frequence distribution of empirical percentages of occurrence in the large toss.
Finaly, using fd again will not produce new results.
Each of the things that I have mention are things to work out for yourself in
the future. You have made impressive progress in mastering challenge.
Keep writing!
Linda
oneCup=: ,:2# 4 6 8 12 20
oneCup
4 4 6 6 8 8 12 12 20 20
tosses=:+/"1@(1 + ?@#&oneCup)
tosses
+/"1@(1 + ?@#&(,:4 4 6 6 8 8 12 12 20 20))
fd=: (~.,. #/.~)tosses 5e5
fd
74 3971
71 6377
36 4049
59 17238
47 14176
43 10222
63 13979
42 9369
67 10357
49 16064
55 18328
40 7081
57 18450
76 2658
58 17654
51 17100
69 8242
45 12380
60 17038
46 13438
61 15913
75 3262
44 11190
35 3305
52 17710
53 18219
54 18413
38 5426
64 13064
56 18316
65 12240
68 9217
37 4711
50 16826
70 7257
48 15224
66 11276
72 5423
31 1309
62 15104
81 800
34 2690
29 817
79 1349
78 1717
80 1037
73 4721
77 2201
39 6201
41 8202
28 571
33 2194
83 424
82 543
32 1792
86 142
87 92
30 1055
27 393
26 286
21 35
22 58
84 300
85 211
25 200
91 11
24 134
90 15
23 96
89 37
88 56
92 7
18 4
93 4
16 2
20 15
19 8
94 2
17 2
1e5=+/1{"1 fd
0
500000=+/1{"1 fd
1
4!:0 ;:'oneCup tosses fd'
0 3 0
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Raul Miller
Sent: Friday, December 09, 2011 1:09 PM
To: Programming forum
Subject: Re: [Jprogramming] Many Turkey Rolls - No embargo
On Fri, Dec 9, 2011 at 12:14 PM, Linda Alvord <[email protected]> wrote:
> Create a frequency distribution fd of your data. How many of each possible
> toss occurred. The possibilities are from 5 and 100 inclusive.
This cannot be right. Either we are throwing one of each of the
polyhedral dice and the possibilities are from 5 through 50, or we are
throwing two of each of the polyhedral dice and the possibilities are
from 10 through 100. Currently I am leaning towards the "two of each"
interpretation.
That leaves me with:
oneCup=: ,:2# 4 6 8 12 20 NB. noun
tosses=: +/"1@(1 + ?@#&oneCup) NB. verb
fd=: (~.,. #/.~) tosses 5e5 NB. noun
(And, yes, my earlier suggestion had a bug - a six sided dice would
have numbers ranging from 0 through 5.)
> Then make purr . This is also a frequency distribution but the results
> should be percent of the total tosses each possible result. The total of
> these 96 percents should have a sum of 100% . This can be affirmed with
> assert. It checks the frequency distribution to be sure that your percentages
> are correct.
This would be:
purr=: fd %("1) 1 _<.+/fd*0.01
Except here I see that you are suggesting that I have a bucket for
each possible option, which typically will not happen. 10 will occur
approximately one time in 2 trillion rolls:
*/&.:%,oneCup
2.12337e9
So let's revisit fd:
fd=: (~.,. #/.~ - 1:) (10}.i.1++/,oneCup),tosses 5e5
purr=: fd %("1) 1 _<.+/fd*0.01
> Are your actual sums in a noun, d, of length 1e5 ? This list needs to be
> tallied in a frequency distribution.Then also do a frequency distribution of
> percentages. Write the verb purr
>
> fdrm=:
> fdrm
> Tally of totals
What are the arguments of fdrm?
Possibilities include;
''
5e5
(,oneCup); 5e5
oneCup; 5e5
5e5$ oneCup
1 + ? 5e5$ oneCup
> Purrrm=:
> purrrm d
> Tallies converted to percentages
What are the arguments of Purrrm? This could be the same arguments
that fdrm takes or it could be the result of fdrm.
> Purr has the sound of PERcent. Sorry if the playful name bothered you.
I have no problem with the name. Some time I should tell you about
the parser I wrote where all of the names came from the Flintstones,
because I could not think of anything better.
Hopefully my above comments, interleaved with text you wrote, make my
problems clearer.
Thanks,
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm