I have a degree in Mathematics and Physics from the Danish University Aarhus, comparable to a masters degree with thesis - majoring in Mathematics. In 1991-92 I was a visting scholar at UCLA, Los Angeles, following graduate courses in Applied Mathematics. Since 1992 I have been a teacher in a high school (gymnasium) in Denmark. Special interests: Applied mathematics, graphics and popularizing Mathematics.

MaplePrimes Activity

These are replies submitted by erik10

Thanks to both of you, Carl Love and Acer. Very valuable information indeed.


@Daniel Skoog Thanks for the information, Daniel. 

@Kitonum Thanks a lot, Kitonum. I appreciate it!



@Carl Love Indeed very compact. Just what I was looking for. Thanks a lot!


@acer For the sake of completeness in this specific situation it would however be appropriate to have all possible values of X listed. Obviously the difference only show up for small sample sizes, where a frequency might turn out to be 0. 

@acer Thanks to both of you. It is also apparent that when choosing big samples, your code is qite a lot faster!


@acer In addition to your fine histograms, I wanted to calculate the actual sample frequencies. With your list M of possible values for the Random Variable X I did it this way:

Isn't there an even more simple way of doing it? I mean I was surprised not to be able to find a command in the Statistics package which could give the frequencies of a list of numbers right away. Maybe I overlooked something?


@mmcdara Very illustrative indeed!!

@acer Big thanks to you and mmcdara for a splendid work! It has certainly helped my investigations in the department of Random Variables. I guess it isn't possible to easily calculate the probability distributions of Random Variables built on other Random Variables in general. The possibilities are simply too complex. In the case of finite Sample Space you have however shown a way to search or go through all possible outcomes and that way get to the probability distribution. I think I am empty for more questions at the moment :)

@acer Your way of making an animation was indeed ingenious. So now my questions regarding samples are settled. 

I am still working on building intuition in relation to how Maple handles Random Variables. Beside being able to calculate Mean and Variance, I am interested in calculating probablities (including cumulative ones - CDF). In the present example with the player against the banker I cannot make it work. I receive a FAIL. I guess it happens because it is necessary to "invert the problem" internally and that Maple isn't capable of doing so - directly at least. In the following let X equal the profit in one play, viewed from the Players viewpoint. Manually one need to ask: What are the possible combinations of dice, which will yield the value 3 for X? The answer is (2,5), (3,6), (5,2) and (6,3). Each with probability 1/36, so the correct answer is 4/36. But Maple can't do it directly. Is there a smart non-ad hoc way to make problems like this work? (one which doesn't require the user to know the answer beforehand). I tried the technique with the old Random Variable Y = Dice1+Dice2, and it works! But here Maple doesn't need to do "back-tracking" in order to compute the probabilities ...



Best regards,



@acer That was impressing! I will have to look into that one tomorrow. Thanks a lot!


@mmcdara This is indeed nice. Thank you!

@tomleslie Yes one need to be careful about algebraic expressions involving those calls for random draws :)

Now that histograms for samples of the Random Variable connected to the Player/banker (call it X) is established, I was looking for a way to define or create the Random Variable X in Maple in the hope Maple could itself calculate the theoretical Mean and Variance (not for a sample). I looked at the commands Distribution and RandomVariable in the Statistics package. The few examples in the Help menu didn't help me much, though. Maybe it is not something one should do here?


@tomleslie Certainly I was aware of the reason why my command failed. Nice solution by defining the piecewise function first and then inserting Dice1() and Dice2() in order for the piecewise command to use the same draw in the entire command. 

Interesting what Carl Love tells below, by the way!



I prefer the histograms for my purpose, but the pointplot option is nice to know for other occasions. I like your improvement of the histogram by using the binbound option. The previous histograms had what seems like arbitrary binwidth and the bins were also placed somewhat arbitrarily. 

Next I am looking at a new Random Variable: The new Random Variable mimics the profit in one play from the viewpoint of a player playing against a banker. The player throws two dice. If one of the dice shows 1 dot, the player looses 4 dollars (therefore the value -4). On all other occasions the player wins the difference of the dots of the two dice, in dollars. All together this means the following possible values for the Random Variable: -4, 0, 1, 2, 3, 4.  

In my attached Maple document (sorry it is in Document Mode), I have made an attempt. Unfortunately the command 'piecewise' is not working here. The impossible value 5 has a nonzero frequency. It must be because the Dice1() and Dice2() are called twice (in the condition and later in the value calculated if the second condition is relevant), thereby applying different values. Maybe I need to assign the values of the two dice to two temporary variables and make an if ... do statement? Is there a convenient quick way? 

Now my samples are well done. It would be nice to have Maple calculate the correct frequencies. Obviously we have:



It would be extremely nice if Maple could somehow calculate it automatically from the definitions of the Random Variable involved. Maybe this need a setup like mmcdara?

Finally there is one request, which is not a must for me to be able to do, but would be real nice: Having Maple calculate and display results on the fly. I don't think it is possible in Maple, but I may be wrong. Some applets out there can show how the frequencies of a sample is approaching the real mean as time go. For educational purposes it would be great in order to show the "law of big numbers" in action!

Thanks for all your suggestions so far ...



1 2 3 4 5 6 7 Last Page 2 of 16