I am currently writing on a code to get RandomNumbers which are geometrical distributed.
But i need the output in one list because i want to plot the output Can anyone help me? Here is the current Code:
m := 20
k = RandomReal[{0, 1}, m];
n := 9
p := 0.40
Liste1 = CDF[GeometricDistribution[p], Range[0, n]];
For[
j = 1,
j < m + 1,
j++,
{
For[i = 1, i < n + 1, i++, If[k[[j]] < Liste1[[i]], Break[]]]; i - 1
}
Print[{i - 1, PDF[GeometricDistribution[p], i - 1]}]
]

Tableinstead ofFor. (Foris also very slow in Mathematica because, in constrast to C, there is no compiler that optimizes it away.) Moreover, Mathematica is not Maple or Pascal: The assignment operator isEqual(=), notSetDelayed(:=). The latter is used in combination with patterns for defining functions. – Henrik Schumacher Feb 09 '19 at 10:34RandomVariate[GeometricDistribution[p]]and take it from there. – High Performance Mark Feb 09 '19 at 10:41