diff --git a/schule/mathe/calc/lib/binomialverteilung.jl b/schule/mathe/calc/lib/binomialverteilung.jl new file mode 100644 index 0000000..60e05ab --- /dev/null +++ b/schule/mathe/calc/lib/binomialverteilung.jl @@ -0,0 +1,32 @@ +""" +# Variablen +- n: Anzahl der Versuche +- p: Chance für erfolgreichen Versuch +- x: Anzahl der zu berechnenden erfolgreichen Versuche +""" +module Binomialverteilung + +""" +# Variablen +- `n`: Anzahl der Versuche +- `p`: Chance für erfolgreichen Versuch +""" +erwartungswert(n, p) = n * p + +""" +# Variablen +- `n`: Anzahl der Versuche +- `p`: Chance für erfolgreichen Versuch +""" +standardabweichung(n, p) = sqrt(n * p * (1 - p)) + +""" +# Variablen +- `x`: Anzahl der zu berechnenden erfolgreichen Versuche +- `n`: Anzahl der Versuche +- `p`: Chance für erfolgreichen Versuch +""" +function verteilung(x, n, p) + binomial(n, x) * p^x * (1-p)^(n-x) +end +end # of module diff --git a/schule/mathe/jupyter/julia.jl b/schule/mathe/jupyter/julia.jl new file mode 100644 index 0000000..58139df --- /dev/null +++ b/schule/mathe/jupyter/julia.jl @@ -0,0 +1,14 @@ +function mittelwert(list::Vector{<:Tuple{<:Real, <:Real}}) + upper_sum = sum(wert * anzahl for (wert, anzahl) in list) + total_count = sum(anzahl for (_, anzahl) in list) + return upper_sum/total_count +end + + +input = [ + (1,0) + (3,0.4) + (5,6) +] + +mittelwert(input) diff --git a/shell.nix b/shell.nix index ed69254..18aac85 100644 --- a/shell.nix +++ b/shell.nix @@ -10,14 +10,15 @@ mermaid-cli # for math - python312 - python312Packages.sympy - python312Packages.numpy - python312Packages.matplotlib - python312Packages.scipy - python312Packages.pandas - python312Packages.jupyter - python312Packages.ipykernel + python313 + python313Packages.sympy + python313Packages.numpy + python313Packages.matplotlib + python313Packages.scipy + python313Packages.pandas + python313Packages.jupyter + python313Packages.ipykernel + julia-bin # for the project pre-commit