You roll two dices. Find the expected value of the sum you'll get.
Bonus: Can you Generalise it to n number of dice ?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Excellent work @Mahdi Raza . Thanku for sharing your solution.
Log in to reply
Thanks, glad you like it! Quite simply actually!
Log in to reply
As I said it's an easy problem.
My solution was Expected value = ((lowest value) + (highest value))/2
Expected value = (n + 6n)/2
Expected value = 3.5n
But yours is an elegant one. :)
@Mahdi Raza Even I thought similarly by thinking of the average face, but as you have written the solution, I don't want to write again. Also, a pattern arises if you plot the sample spaces. @Aryan Sanghi great question!
You are right! I have a lot of die and time, so I tested it with 1 , 2 , 3 ⋯ 1 0 0 dice. The avarage sums with 10,000,000 rolls are:
1 | 3.5000013 |
2 | 6.9989863 |
3 | 10.4998481 |
4 | 13.9971883 |
5 | 17.5013234 |
6 | 20.9986741 |
7 | 24.4981529 |
8 | 27.9999454 |
9 | 31.5005634 |
10 | 34.9972343 |
11 | 38.5002841 |
12 | 42.16247 |
13 | 45.4980172 |
14 | 48.9981100 |
15 | 52.4980437 |
16 | 55.9994406 |
17 | 59.4982269 |
18 | 62.9968936 |
19 | 66.4947381 |
20 | 69.9968198 |
21 | 73.4973500 |
22 | 76.9961685 |
23 | 80.4979282 |
24 | 84.19010 |
25 | 87.4952486 |
26 | 90.9986911 |
27 | 94.4976375 |
28 | 97.9919740 |
29 | 101.4956757 |
30 | 104.9940632 |
31 | 108.4983679 |
32 | 111.9977235 |
33 | 115.4972338 |
34 | 118.9973354 |
35 | 122.4920760 |
36 | 125.9942138 |
37 | 129.4956380 |
38 | 132.9968175 |
39 | 136.4984199 |
40 | 139.9950933 |
41 | 143.4914077 |
42 | 146.9943447 |
43 | 150.4989645 |
44 | 153.9929684 |
45 | 157.4961524 |
46 | 160.9889031 |
47 | 164.4948546 |
48 | 167.9979304 |
49 | 171.4962770 |
50 | 174.9896285 |
51 | 178.4913413 |
52 | 181.9985439 |
53 | 185.4959921 |
54 | 188.9874608 |
55 | 192.4917256 |
56 | 195.9977068 |
57 | 199.4945960 |
58 | 202.9884386 |
59 | 206.4911641 |
60 | 209.9979973 |
61 | 213.4920127 |
62 | 216.9874371 |
63 | 220.4982939 |
64 | 223.9921324 |
65 | 227.4882880 |
66 | 230.9920185 |
67 | 234.4941657 |
68 | 237.9898166 |
69 | 241.4896067 |
70 | 244.9936467 |
71 | 248.4904991 |
72 | 251.9895294 |
73 | 255.4940553 |
74 | 258.9898544 |
75 | 262.4895043 |
76 | 265.9958375 |
77 | 269.4868072 |
78 | 272.9924676 |
79 | 276.4925781 |
80 | 279.9838065 |
81 | 283.4940814 |
82 | 286.9893526 |
83 | 290.4871943 |
84 | 293.9948063 |
85 | 297.4856383 |
86 | 300.9929921 |
87 | 304.4891023 |
88 | 307.9846959 |
89 | 311.4956685 |
90 | 314.9830647 |
91 | 318.4934824 |
92 | 321.9854683 |
93 | 325.4913286 |
94 | 328.9897604 |
95 | 332.4826614 |
96 | 335.9931466 |
97 | 339.4903680 |
98 | 342.9859449 |
99 | 346.4901426 |
100 | 349.9809587 |
Log in to reply
Excellent job @Páll Márton
Did u code this? I mean how did you get decimal values. The formula 3.5n suggests that the sum is close to it.
Log in to reply
For you and @Aryan Sanghi :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
Log in to reply
@A Former Brilliant Member – Excellent code. But, why don't you use <bits/stdc++.h>, you won't need to include so many files then. Just one file and it's done.
Log in to reply
@Aryan Sanghi
–
I hate the
.h
headers :) But sometimes they are necessary.
Log in to reply
@A Former Brilliant Member – Why? Did something wrong happen with them?
Log in to reply
@Aryan Sanghi – No. Just .h is seems outdated.
Log in to reply
@A Former Brilliant Member – But, after sometime, you'll need them desperately like when you design your own games/apps. You can't write a long code in one file, so you'll have to write your code in multiple files and have to save them with .h extension and have to include them. Also, many important header files are .h like <graphics.h>.
So, I think you should start liking them. Just a suggestion.
@Aryan Sanghi – And the C++ is outdated too :)
Log in to reply
@A Former Brilliant Member – Actually, it's the language which is used mos after python. It is the one which is used to write core code of 90% files. So, you say it to be outdated.
Log in to reply
@Aryan Sanghi – I wrote a code, but I used brute-force, so it was a very slow code, so I had to use % and pow, but we can't in one argument use both!!! So I wrote a 200-lines code to get the product of two vectors, and another code to get the % of two vectors. But the code was too long...(memory and time limit)
Log in to reply
@A Former Brilliant Member – Actually I'll send you a link. It evaluates power in l o g n time complexity. That is why I say you to start Competitive programming, it teaches how to write efficient codes.
Considering time and memory, I'll try to write a efficient code when as soon as I get time and will post the code.
@A Former Brilliant Member – Here is the link to power in l o g n time complexity.
Log in to reply
@Aryan Sanghi – Ok, but what will be if x=157986453215668516535400653515305403378306835468873210? :) I used big numbers, so I should use vectors.
Log in to reply
@A Former Brilliant Member – No, you could convert it to string and then use a variant of the link
Log in to reply
@Aryan Sanghi – What about x > 1 0 5 0 0 ?
Log in to reply
@A Former Brilliant Member – Still the same. It is valid till 10 1 0 0 0 0 0 0
Log in to reply
@Aryan Sanghi – Oh! But we can do with a string only those things, what we can do with a vector. And in a vector we can use integers.
Log in to reply
@A Former Brilliant Member – Yes, I know about vectors
Use string data type, it's a vector of characters
@A Former Brilliant Member
–
There was a little typo in the 12th line :)
for(int n=100;n<101;n++){
instead of
for(int n=1;n<101;n++){
@A Former Brilliant Member – I am learning to code, but what you have done is great! Hats off.
A C++ code?
Here is a table of outcomes
Sum | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
Frequency | 1 | 2 | 3 | 4 | 5 | 6 | 5 | 4 | 3 | 2 | 1 |
Short answer As 7 is the symmetrical term, it is the answer.
Average face is:
6 1 × ( 1 + 2 + 3 + 4 + 5 + 6 ) = 3 . 5
This is rolled n times to give:
3 . 5 × n
Log in to reply
Did you try my question Unexpected Probability problem!! 2
Here is a chart with all of the possible numbers you can roll. As you can see, 7 is the most likely to happen.
Actually, expected value is not the most likely number. It's the average of all values that you will get if you roll the dice infinitely.
That is intresting
If a is the lowest number you can get on a die, b is the highest, and c is the number or dice, the equation is (a+b/2)*c.
'Dices' is not a word. It is supposed to be 'dice'.
Problem Loading...
Note Loading...
Set Loading...
[Bonus]
Average face is:
6 1 × ( 1 + 2 + 3 + 4 + 5 + 6 ) = 3 . 5
This is rolled n times to give:
3 . 5 × n
We can create square-grids in 2D (for two rolls), cube-grids in 3D (for three rolls) and so on... But to visualize n dice-rolls it gets cumbersome and messy to see this beyond 2D.