Message Boards Message Boards

1
|
4276 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Score Distribution

Posted 10 years ago

Re Mathematica 10.0.2 under Windows 8.1.

In the last line below, what role does "Weights" play? It's not an argument to scoreDistribution yet without "Weights", the code fails. Its role baffles me. Thanks.

scoreDistribution[n_Integer?Positive, sides_Integer: 6] /; sides > 1 :
  Block[{z, pgf},
   pgf = Cancel[
     FactorialMomentGeneratingFunction[
      DiscreteUniformDistribution[{1, sides}], z]/z]^n;
   EmpiricalDistribution[CoefficientList[pgf, z] -> Range[n, n sides]]
   ];

scoreDistribution[100]["Weights"] // ListPlot[#, PlotRange -> All] &
POSTED BY: Bruce Colletti
2 Replies
Posted 10 years ago

Unfortunately my response is probably more commiserating than helpful. I found that the resulting object from scoreDistribution is a DataDistribution object of dimension 4 with a few other named properties (although I didn't get the function above to work exactly as written):

In[34]:= n = 100;
sides = 2;
pgf = Cancel[
    FactorialMomentGeneratingFunction[
      DiscreteUniformDistribution[{1, sides}], z]/z]^n;
w = EmpiricalDistribution[
   CoefficientList[pgf, z] -> Range[n, n sides]];

Dimensions[w]
w["Type"]
w[[1]]
w["Domain"] == w[[2]][[2]]
w["Dimension"] == w[[3]]
w["Weights"] == w[[2]][[1]]
w[[4]]  (* Number of elements in the sample space *)


Out[38]= {4}

Out[39]= EmpiricalDistribution

Out[40]= "Empirical"

Out[41]= True

Out[42]= True

Out[43]= True

Out[44]= 101

I didn't figure out the associated name with w[[4]] (the number of data points).

Correction: Simpler than I thought to get the properties.

In[57]:= w["Properties"]

Out[57]= {"Dimension", "Domain", "SampleSize", "Type", "Weights"}
POSTED BY: Jim Baldwin
Posted 10 years ago

Jim, this is fantastic, answers my question, and revealed something important that was new to me (the Properties). Thanks!

Bruce

POSTED BY: Bruce Colletti
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract