From 100498089783148753f2862c4dbfba04f110727f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Wed, 9 Mar 2022 09:42:50 +0100 Subject: add order statistics graph --- buch/papers/dreieck/images/order.m | 79 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 buch/papers/dreieck/images/order.m (limited to 'buch/papers/dreieck/images/order.m') diff --git a/buch/papers/dreieck/images/order.m b/buch/papers/dreieck/images/order.m new file mode 100644 index 0000000..d37a258 --- /dev/null +++ b/buch/papers/dreieck/images/order.m @@ -0,0 +1,79 @@ +# +# order.m +# +# (c) 2022 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +# +global N; +N = 10; +global subdivisions; +subdivisions = 100; +global P; +P = 0.5 + +function retval = orderF(p, n, k) + retval = 0; + for i = (k:n) + retval = retval + nchoosek(n,i) * p^i * (1-p)^(n-i); + end +end + +function retval = orderd(p, n, k) + retval = 0; + for i = (k:n) + s = i * p^(i-1) * (1-p)^(n-i); + s = s - p^i * (n-i) * (1-p)^(n-i-1); + retval = retval + nchoosek(n,i) * s; + end +end + +function orderpath(fn, k, name) + fprintf(fn, "\\def\\order%s{\n\t(0,0)", name); + global N; + global subdivisions; + for i = (0:subdivisions) + p = i/subdivisions; + fprintf(fn, "\n\t-- ({%.4f*\\dx},{%.4f*\\dy})", + p, orderF(p, N, k)); + end + fprintf(fn, "\n}\n"); +end + +function orderdpath(fn, k, name) + fprintf(fn, "\\def\\orderd%s{\n\t(0,0)", name); + global N; + global subdivisions; + for i = (1:subdivisions-1) + p = i/subdivisions; + fprintf(fn, "\n\t-- ({%.4f*\\dx},{%.4f*\\dy})", + p, orderd(p, N, k)); + end + fprintf(fn, "\n\t-- ({1*\\dx},0)"); + fprintf(fn, "\n}\n"); +end + +fn = fopen("orderpath.tex", "w"); +orderpath(fn, 0, "zero"); +orderdpath(fn, 0, "zero"); +orderpath(fn, 1, "one"); +orderdpath(fn, 1, "one"); +orderpath(fn, 2, "two"); +orderdpath(fn, 2, "two"); +orderpath(fn, 3, "three"); +orderdpath(fn, 3, "three"); +orderpath(fn, 4, "four"); +orderdpath(fn, 4, "four"); +orderpath(fn, 5, "five"); +orderdpath(fn, 5, "five"); +orderpath(fn, 6, "six"); +orderdpath(fn, 6, "six"); +orderpath(fn, 7, "seven"); +orderdpath(fn, 7, "seven"); +orderpath(fn, 8, "eight"); +orderdpath(fn, 8, "eight"); +orderpath(fn, 9, "nine"); +orderdpath(fn, 9, "nine"); +orderpath(fn, 10, "ten"); +orderdpath(fn, 10, "ten"); +fclose(fn); + + -- cgit v1.2.1 From 97931f8f854d0b18dc5c0cb3cb2fecae922f81a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Sun, 13 Mar 2022 11:05:56 +0100 Subject: add beta distribution graphs --- buch/papers/dreieck/images/order.m | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'buch/papers/dreieck/images/order.m') diff --git a/buch/papers/dreieck/images/order.m b/buch/papers/dreieck/images/order.m index d37a258..762f458 100644 --- a/buch/papers/dreieck/images/order.m +++ b/buch/papers/dreieck/images/order.m @@ -26,6 +26,10 @@ function retval = orderd(p, n, k) end end +function retval = orders(p, n, k) + retval = k * nchoosek(n, k) * p^(k-1) * (1-p)^(n-k); +end + function orderpath(fn, k, name) fprintf(fn, "\\def\\order%s{\n\t(0,0)", name); global N; @@ -51,29 +55,65 @@ function orderdpath(fn, k, name) fprintf(fn, "\n}\n"); end +function orderspath(fn, k, name) + fprintf(fn, "\\def\\orders%s{\n\t(0,0)", name); + global N; + global subdivisions; + for i = (1:subdivisions-1) + p = i/subdivisions; + fprintf(fn, "\n\t-- ({%.4f*\\dx},{%.4f*\\dy})", + p, orders(p, N, k)); + end + fprintf(fn, "\n\t-- ({1*\\dx},0)"); + fprintf(fn, "\n}\n"); +end + fn = fopen("orderpath.tex", "w"); + orderpath(fn, 0, "zero"); orderdpath(fn, 0, "zero"); +orderspath(fn, 0, "zero"); + orderpath(fn, 1, "one"); orderdpath(fn, 1, "one"); +orderspath(fn, 1, "one"); + orderpath(fn, 2, "two"); orderdpath(fn, 2, "two"); +orderspath(fn, 2, "two"); + orderpath(fn, 3, "three"); orderdpath(fn, 3, "three"); +orderspath(fn, 3, "three"); + orderpath(fn, 4, "four"); orderdpath(fn, 4, "four"); +orderspath(fn, 4, "four"); + orderpath(fn, 5, "five"); orderdpath(fn, 5, "five"); +orderspath(fn, 5, "five"); + orderpath(fn, 6, "six"); orderdpath(fn, 6, "six"); +orderspath(fn, 6, "six"); + orderpath(fn, 7, "seven"); orderdpath(fn, 7, "seven"); +orderspath(fn, 7, "seven"); + orderpath(fn, 8, "eight"); orderdpath(fn, 8, "eight"); +orderspath(fn, 8, "eight"); + orderpath(fn, 9, "nine"); orderdpath(fn, 9, "nine"); +orderspath(fn, 9, "nine"); + orderpath(fn, 10, "ten"); orderdpath(fn, 10, "ten"); +orderspath(fn, 10, "ten"); + fclose(fn); -- cgit v1.2.1