[Chicago] Throw those dice!!!!

Lewit, Douglas d-lewit at neiu.edu
Tue Aug 4 09:14:37 CEST 2015


Hi Joshua,

The expected value for two dice is going to be 7.  That makes sense because
there are 5 or 6 ways to create the sum of 7 with two dice, while all other
sums will have fewer frequencies.  Obviously as you start rolling more and
more dice, the expected value will change.  If you are rolling 8 dice, a
sum of 7 isn't even possible!  (Cause if you get 1's on all 8 dice, then
your minimum possible sum has to be 8, right?)  Using Mathematica and also
Matplotlib I generated several histograms for these problems.  Based on my
observations, these frequency distributions appear normally distributed.

I took an intro C++ course at Oakton College a couple years back.  The
professor used to live in Las Vegas and really LOVED casino mathematics,
probability, statistics and writing programs to simulate games of chance.
It was just an intro course, so we didn't get into a lot of hardcore stuff,
but it was sure interesting.

As a side note, C++ can be a strange language!  I loved writing C++
programs on my Mac, but was very disappointed to discover that most of my
C++ programs that ran on my Mac definitely did not run properly or even
compile on the Windows and Linux computers at the college.  Then I
discovered the reason.  There are different flavors of C/C++ depending on
which operating system you use.  Apple has its own version of C/C++, which
is slightly different from the GNU version of C/C++.  How confusing!  What
I like about Java, Python, Ruby, etc, is that these newer languages are
basically "one size fits all" or "one universal compiler/interpreter for
all operating systems".  I'm pretty sure that's why Java eventually
replaced C/C++ as the "king" of object-oriented programming languages.
Java has the advantage of platform-independence.  The same with Python,
right?

On Sun, Aug 2, 2015 at 8:16 PM, Joshua Herman <zitterbewegung at gmail.com>
wrote:

> Dear Lewitt,
> What is the expected value of two die rolls? Also, given N dice rolls
> could I create a compression algorithm for those dice rolls?
> Sincerely,
> Joshua Herman
>
> On Sun, Aug 2, 2015 at 8:04 PM Lewit, Douglas <d-lewit at neiu.edu> wrote:
>
>> Hey guys,
>>
>> I will admit that I'm rather proud of this little Python program that I
>> wrote, but for values larger than 6 either the program crashes because of a
>> stack overflow or the program becomes really painfully SLOW!
>>
>> Let me explain what this program does.  Let's say that you roll two
>> dice.  What are all the possible sums.  If both dice land with the one-side
>> face up, that's a sum of 2.  If both dice land with the six-side face up,
>> that is 6 + 6, which gives you a sum of 12.  Then you have all the sums in
>> between.  Any student of statistics will tell you that these sums are NOT
>> all equally probable or equally likely.  For example, in the case of two
>> dice, the most probable sum is 7 because there are several ways to get that
>> sum.  First die = 3, second die = 4, {3, 4} or {4, 3} or {5, 2} or {2, 5}
>> or {1, 6} or {6, 1} or ..... get the idea?
>>
>> But why limit ourselves to just two dice?  What about three dice?  Or
>> four dice?  Or five dice?  Or six dice?  Or any number of dice that we
>> choose to throw?
>>
>> My approach works pretty well for any number of dice from 1 to 6.  Beyond
>> 6 however, that's when I run into some real problems.
>>
>> Is there an "easy" way to fix this?  Probably not, but I thought I would
>> check with people who are more experienced in Python than I am.
>>
>> I appreciate the feedback, but may not be able to reply until next
>> weekend.  I'm VERY busy this week!  But still I appreciate any constructive
>> feedback that you can provide.
>>
>> Many thanks,
>>
>> Douglas Lewit
>>
>> _______________________________________________
>> Chicago mailing list
>> Chicago at python.org
>> https://mail.python.org/mailman/listinfo/chicago
>>
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> https://mail.python.org/mailman/listinfo/chicago
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20150804/d9bd9d53/attachment.html>


More information about the Chicago mailing list