[Android Apps and Games] Tintinnuntius:
And the final ones for today, these two scripts compute the probabilities for two well-known discrete probability distributions and draw a schematic representation.

View attachment 2524311

Poisson: parameters are lambda = the expected value (and arbitrary positive real number) and k = the maximum value for which P(X=i) should be calculated and ploted (a positive integer).

strokewidth = LN.getStrokeWidth();
head = 5*strokewidth;
open = 0.4;
headcos = head * Math.cos(open);
headsin = head * Math.sin(open);
x1 = LN.getX1();
y1 = LN.getY1();
x2 = LN.getX2();
y2 = LN.getY2();
red = LN.getRed();
green = LN.getGreen();
blue = LN.getBlue();
xmin = Math.min(x1, x2);
ymin = Math.min(y1, y2);
xmax = Math.max(x1, x2);
ymax = Math.max(y1, y2);
xavail = Math.max(0, xmax - xmin - headsin - 2 * headcos);
yavail = Math.max(0, ymax - ymin - headsin - 2 * headcos);
xorigin = headsin;
yorigin = headsin;
l = LN.getParameter(1);
k = LN.getParameter(2);
a = 0.9*(ymax-ymin);
b = xmin + xorigin;
d = ymax-yorigin;
n = (xmax-xmin)*0.9/k;
c = (xmax-xmin);
LN.setStrokeWidth(3*strokewidth);
fac = 1;
for (i=1; i<=k ; i++){
fac = fac*i;
LN.drawLine(b+i*n,d-strokewidth,b+i*n,-a*(Math.pow(l,i)*Math.exp(-l)/fac)+d+strokewidth);
}
LN.setStrokeWidth(strokewidth);
LN.setColor(0,0,0);
LN.drawLine(xmin+xorigin, ymin + headcos, xmin +xorigin , ymax);
LN.drawFilledTriangle(xmax - headcos, ymax - yorigin + headsin, xmax, ymax - yorigin, xmax - headcos, ymax - yorigin - headsin);
LN.drawFilledTriangle( xmin + xorigin - headsin, ymin + headcos, xmin + xorigin , ymin, xmin + xorigin + headsin, ymin + headcos);
LN.setStrokeWidth(3*strokewidth);
LN.setColor(red,green,blue);
LN.drawLine(b,d-strokewidth,b,-a*Math.exp(-l)+d+strokewidth);
LN.drawPoint(b,d-a);
LN.setColor(0,0,0);
LN.setTextSize(16);
LN.drawText(1,b+10,d-a+6);
LN.drawText(Math.exp(-l),(xmin+xmax)/2,-a+d+6);
fac = 1;
for (i=1; i<=k ; i++){
fac = fac*i;
LN.drawText(Math.pow(l,i)*Math.exp(-l)/fac,(xmin+xmax)/2,-a+d+6+18*i);
}
LN.setStrokeWidth(strokewidth);
LN.drawLine(xmin, ymax - yorigin, xmax - headcos, ymax - yorigin);

Geometric: parameters are p = the probability of a certain event occuring in one trial (a real between 0 and 1) and k = the maximum value for which P(X=i) should be calculated and ploted (a positive integer).

strokewidth = LN.getStrokeWidth();
head = 5*strokewidth;
open = 0.4;
headcos = head * Math.cos(open);
headsin = head * Math.sin(open);
x1 = LN.getX1();
y1 = LN.getY1();
x2 = LN.getX2();
y2 = LN.getY2();
red = LN.getRed();
green = LN.getGreen();
blue = LN.getBlue();
xmin = Math.min(x1, x2);
ymin = Math.min(y1, y2);
xmax = Math.max(x1, x2);
ymax = Math.max(y1, y2);
xavail = Math.max(0, xmax - xmin - headsin - 2 * headcos);
yavail = Math.max(0, ymax - ymin - headsin - 2 * headcos);
xorigin = headsin;
yorigin = headsin;
p = LN.getParameter(1);
k = LN.getParameter(2);
q = 1-p;
a = 0.9*(ymax-ymin);
b = xmin + xorigin;
d = ymax-yorigin;
n = (xmax-xmin)*0.9/k;
c = (xmax-xmin);
LN.setStrokeWidth(3*strokewidth);
for (i=1; i<=k ; i++){
LN.drawLine(b+i*n,d-strokewidth,b+i*n,-a*p*Math.pow(q,i)+d+strokewidth);
}
LN.setStrokeWidth(strokewidth);
LN.setColor(0,0,0);
LN.drawLine(xmin+xorigin, ymin + headcos, xmin +xorigin , ymax);
LN.drawFilledTriangle(xmax - headcos, ymax - yorigin + headsin, xmax, ymax - yorigin, xmax - headcos, ymax - yorigin - headsin);
LN.drawFilledTriangle( xmin + xorigin - headsin, ymin + headcos, xmin + xorigin , ymin, xmin + xorigin + headsin, ymin + headcos);
LN.setStrokeWidth(3*strokewidth);
LN.setColor(red,green,blue);
LN.drawLine(b,d-strokewidth,b,-a*p+d+strokewidth);
LN.drawPoint(b,d-a);
LN.setColor(0,0,0);
LN.setTextSize(16);
LN.drawText(1,b+10,d-a+6);
for (i=0; i<=k ; i++){
LN.drawText(p*Math.pow(q,i),(xmin+xmax)/2,-a+d+6+18*i);
}
LN.setStrokeWidth(strokewidth);
LN.drawLine(xmin, ymax - yorigin, xmax - headcos, ymax - yorigin);