- #281
- 3,320
- 8,810
I need a translation pleaseberkeman said:
O##\pi##nionpinball1970 said:I need a translation please
o(pi)nionpinball1970 said:I need a translation please
He who laughs last on this thread needs to study more mathematics!Baluncore said:He who laughs last, laughs longest.
And another - four equal sides and contains four right angles:DaveC426913 said:
Lego actually makes these:DaveC426913 said:
In a similar vein, Kernighan and Ritchie's classic text "The C Programming Language" has an index entry for "recursion", which includes its own page number.pines-demon said:– The Mandelbrot set is named after Benoit B. Mandelbrot
– What does the B. stand for?
– B. stands for Benoit B. Mandelbrot
Almost surely/Shirley.BillTre said:Surely you jest!
May be that's what he meant by happiness.Bandersnatch said:...or a divorce.
collinsmark said:
4 0.0011574074074074073
5 0.004629629629629629
6 0.011574074074074073
7 0.023148148148148147
8 0.03935185185185185
9 0.06018518518518519
10 0.08217592592592593
11 0.10185185185185186
12 0.11574074074074076
13 0.12037037037037036
14 0.11574074074074074
15 0.10185185185185186
16 0.08217592592592593
17 0.06018518518518519
18 0.03935185185185185
19 0.023148148148148147
20 0.011574074074074073
21 0.004629629629629629
22 0.0011574074074074073
4 0.0011574074074074073
5 0.005787037037037037
6 0.017361111111111112
7 0.04050925925925926
8 0.0798611111111111
9 0.14004629629629628
10 0.2222222222222222
11 0.32407407407407407
12 0.4398148148148148
13 0.5601851851851852
14 0.6759259259259259
15 0.7777777777777778
16 0.8599537037037037
17 0.920138888888889
18 0.9594907407407408
19 0.982638888888889
20 0.994212962962963
21 0.9988425925925927
22 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace DiceConvolution
{
internal class IntegerDistribution
{
// public properties
public int startingIndex { get; private set; } // typically the first nonzero index. The first index of importance. For a standard die, this is 1.
public double[] probabilityDensityArray { get; private set; } // The zero based array of probabilities (shifted to start at array index 0).
// constructor
public IntegerDistribution(int startingIndex, double[] probabilityDensityArray)
{
this.startingIndex = startingIndex;
this.probabilityDensityArray = probabilityDensityArray;
}
// methods
public IntegerDistribution convolve (IntegerDistribution a)
{
// create a reversed version of the input a
double[] aReversed = new double[a.probabilityDensityArray.Length];
Array.Copy(a.probabilityDensityArray, aReversed, a.probabilityDensityArray.Length);
Array.Reverse(aReversed);
double[] output = new double[aReversed.Length + probabilityDensityArray.Length - 1];
// Convolution
for (int i = 0; i < output.Length; i++)
{
output[i] = 0;
for(int j = 0; j < aReversed.Length; j++)
{
// Only integrate legal portions of the arrays
if(i - j >= 0 && i - j < probabilityDensityArray.Length)
{
output[i] += probabilityDensityArray[i - j] * aReversed[j];
}
}
}
return new IntegerDistribution(startingIndex + a.startingIndex, output);
}
public IntegerDistribution clone()
{
double[] array = new double[probabilityDensityArray.Length];
Array.Copy(probabilityDensityArray, array, probabilityDensityArray.Length);
return new IntegerDistribution(startingIndex, array);
}
public static IntegerDistribution operator+ (IntegerDistribution a, IntegerDistribution b)
{
return a.convolve(b);
}
public double[] cumulative()
{
double total = 0;
double[] output = new double[probabilityDensityArray.Length];
for (int i = 0;i < output.Length;i++)
{
total += probabilityDensityArray[i];
output[i] = total;
}
return output;
}
public static IntegerDistribution operator* (int a, IntegerDistribution b)
{
IntegerDistribution output = b.clone();
for (int i = 2; i <= a; i++) output += b;
return output;
}
}
}
// Main program
using DiceConvolution;
Console.WriteLine("Hello, World!");
IntegerDistribution D6 = new IntegerDistribution(1, new double[] { 1 / 6.0, 1 / 6.0, 1 / 6.0, 1 / 6.0, 1 / 6.0, 1 / 6.0 });
IntegerDistribution D4 = new IntegerDistribution(1, new double[] { 1 / 4.0, 1 / 4.0, 1 / 4.0, 1 / 4.0 });
IntegerDistribution c = (3 * D6) + D4;
for (int i = 0; i < c.probabilityDensityArray.Length; i++)
{
Console.WriteLine(c.startingIndex + i + " " + c.probabilityDensityArray[i]);
}
Console.WriteLine(Environment.NewLine + Environment.NewLine);
double[] cumulative = c.cumulative();
for (int i = 0; i < c.probabilityDensityArray.Length; i++)
{
Console.WriteLine(c.startingIndex + i + " " + cumulative[i]);
}
I would have been astonished if he wasn't accurate. It's what he does.collinsmark said:I was curious to how meticulous Randall Monroe in his probability calculations. Did he just throw some dice figures in there hoping nobody would check, or was he actually pretty close?
...According to the program, rolling a 15 or below is exactly the same probability of drawing at least one of the cursed arrows. So one would need to roll a 16 or greater to avoid the cursed arrows.
So Randall Monroe was not just close, he was exactly on the mark. Kudos to his attention to detail.