Added Distribution
This commit is contained in:
parent
2776e66c5b
commit
3d2291d619
92
.obsidian/workspace.json
vendored
92
.obsidian/workspace.json
vendored
@ -55,44 +55,16 @@
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Gruppen/MeWi 1.md",
|
||||
"file": "Lectures/06 22.11.2024.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
},
|
||||
"icon": "lucide-file",
|
||||
"title": "MeWi 1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "d4d973e0d0e2e072",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Gruppen/MeWi 2.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
},
|
||||
"icon": "lucide-file",
|
||||
"title": "MeWi 2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "91b08793b1132c55",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Lectures/05 15.11.2024.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
},
|
||||
"icon": "lucide-file",
|
||||
"title": "05 15.11.2024"
|
||||
"title": "06 22.11.2024"
|
||||
}
|
||||
}
|
||||
],
|
||||
"currentTab": 5
|
||||
"currentTab": 3
|
||||
}
|
||||
],
|
||||
"direction": "vertical"
|
||||
@ -210,10 +182,10 @@
|
||||
"state": {
|
||||
"type": "outline",
|
||||
"state": {
|
||||
"file": "Lectures/17 21.02.2025.md"
|
||||
"file": "Lectures/06 22.11.2024.md"
|
||||
},
|
||||
"icon": "lucide-list",
|
||||
"title": "Outline of 17 21.02.2025"
|
||||
"title": "Outline of 06 22.11.2024"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -255,19 +227,33 @@
|
||||
"table-editor-obsidian:Advanced Tables Toolbar": false
|
||||
}
|
||||
},
|
||||
"active": "91b08793b1132c55",
|
||||
"active": "91e68fc77697e0f9",
|
||||
"lastOpenFiles": [
|
||||
"Material/3.Lösungen_Extended_Applications.slides.html",
|
||||
"Material/wise_24_25/Folien/3.Lösungen_Extended_Applications.ipynb",
|
||||
"Material/wise_24_25/Folien/Untitled.ipynb",
|
||||
"Material/wise_24_25/Folien",
|
||||
"Material/wise_24_25/lernmaterial/4.NumPy_MatPlotLib.ipynb",
|
||||
"Material/wise_24_25/lernmaterial/3.Extended_Applications.ipynb",
|
||||
"Material/wise_24_25/lernmaterial/2.Tutorial.ipynb",
|
||||
"Material/wise_24_25/lernmaterial/1.Tutorial.ipynb",
|
||||
"Material/wise_24_25/3.Extended_Applications.ipynb",
|
||||
"Material/wise_24_25/2.Tutorial.ipynb",
|
||||
"Material/wise_24_25/1.Tutorial.ipynb",
|
||||
"Lectures/05 15.11.2024.md",
|
||||
"Gruppen/MeWi 1.md",
|
||||
"Lectures/27.11.2024.md",
|
||||
"Lectures/06 22.11.2024.md",
|
||||
"Material/wise_24_25/lernmaterial/5.SciPy.ipynb",
|
||||
"Material/wise_24_25/lernmaterial/Untitled.ipynb",
|
||||
"Material/Untitled.ipynb",
|
||||
"Timetable.md",
|
||||
"Lectures/16 14.02.2025.md",
|
||||
"Lectures/17 21.02.2025.md",
|
||||
"To Do.md",
|
||||
"Gruppen/Engineering 1.md",
|
||||
"Gruppen/MeWi 7 (DiKum).md",
|
||||
"Gruppen/MeWi 6.md",
|
||||
"Gruppen/MeWi 5.md",
|
||||
"Gruppen/MeWi 4.md",
|
||||
"Gruppen/MeWi 3.md",
|
||||
"Gruppen/MeWi 2.md",
|
||||
"Material/3.Extended_Applications_Lösungen.html",
|
||||
"Material/3.Lösungen_Extended_Applications.html",
|
||||
"Material/wise_24_25/lernmaterial/2.Tutorial_2.ipynb",
|
||||
"Material/wise_24_25/lernmaterial/1.Tutorial_1.ipynb",
|
||||
"Material/testfile.txt",
|
||||
"Material/V4.ipynb",
|
||||
"Material/Tutorial2_Lösungen.ipynb",
|
||||
"Material/env/lib/python3.12/site-packages/matplotlib/mpl-data/sample_data/logo2.png",
|
||||
"Material/env/lib/python3.12/site-packages/matplotlib/mpl-data/sample_data/grace_hopper.jpg",
|
||||
"Material/env/lib/python3.12/site-packages/matplotlib/mpl-data/sample_data/Minduka_Present_Blue_Pack.png",
|
||||
@ -279,17 +265,6 @@
|
||||
"Material/env/lib/python3.12/site-packages/matplotlib/mpl-data/images/subplots.svg",
|
||||
"Material/env/lib/python3.12/site-packages/matplotlib/mpl-data/images/subplots.png",
|
||||
"Lectures/04 08.11.2024.md",
|
||||
"Gruppen/Engineering 1.md",
|
||||
"Gruppen/MeWi 4.md",
|
||||
"Gruppen/MeWi 5.md",
|
||||
"Gruppen/MeWi 3.md",
|
||||
"Gruppen/MeWi 2.md",
|
||||
"Gruppen/MeWi 1.md",
|
||||
"Gruppen/MeWi 7 (DiKum).md",
|
||||
"Gruppen/MeWi 6.md",
|
||||
"To Do.md",
|
||||
"Timetable.md",
|
||||
"Lectures/17 21.02.2025.md",
|
||||
"Lectures/03 01.11.2024.md",
|
||||
"Lectures/02 25.10.2024.md",
|
||||
"README.md",
|
||||
@ -299,9 +274,6 @@
|
||||
"Material/README.md",
|
||||
"Material/ToDo.md",
|
||||
"Student List.md",
|
||||
"Lectures/16 14.02.2025.md",
|
||||
"Material/env/lib/python3.12/site-packages/nbgrader/server_extensions/formgrader/static/components/underscore/README.md",
|
||||
"Material/env/lib/python3.12/site-packages/nbgrader/server_extensions/formgrader/static/components/jquery-color/README.md",
|
||||
"Material/env/lib/python3.12/site-packages/nbgrader/server_extensions/formgrader/static/components/jquery/README.md"
|
||||
"Material/env/lib/python3.12/site-packages/nbgrader/server_extensions/formgrader/static/components/underscore/README.md"
|
||||
]
|
||||
}
|
@ -10,7 +10,7 @@ tags:
|
||||
| Name | Punkte | Durchschnitt | Jupyter Kennung | Mail |
|
||||
| -------------- | ------ | ------------ | -------------------------------- | ------------------------------------------------------------------------- |
|
||||
| Janna Heiny | | | 3140c4b62381a2203803f8b237118244 | [j.heiny@tu-braunschweig.de](mailto:j.heiny@tu-braunschweig.de) |
|
||||
| Milena Krieger | | | 8be9a4cc0b240a18171892b873dc2cb8 | [m.krieger@tu-braunschweig.de](mailto:m.krieger@tu-braunschweig.de) |
|
||||
| Milena Krieger | 30 | | 8be9a4cc0b240a18171892b873dc2cb8 | [m.krieger@tu-braunschweig.de](mailto:m.krieger@tu-braunschweig.de) |
|
||||
| Xiaowei Wang | | | 39dc5bd7686c3280247aacee82c9818e | [xiaowei.wang@tu-braunschweig.de](mailto:xiaowei.wang@tu-braunschweig.de) |
|
||||
| | | | | |
|
||||
| | | | | |
|
||||
|
@ -12,8 +12,8 @@ tags:
|
||||
| Izabel Mike | 29.5 | | 8c710a24debf6159659d1e58dd975ce2 | [i.mike@tu-braunschweig.de](mailto:i.mike@tu-braunschweig.de) |
|
||||
| Lara Troschke | 20.5 | | 7b441c67713f2a49811625905612f19b | [l.troschke@tu-braunschweig.de](mailto:l.troschke@tu-braunschweig.de) |
|
||||
| Inga-Brit Turschner | 25.5 | | 72f0b5fd2cdf4dd808ca9a3add584c75 | [i.turschner@tu-braunschweig.de](mailto:i.turschner@tu-braunschweig.de) |
|
||||
| Yannik Haupt | | | f4f597c57d8a31960750e0647f917ed3 | |
|
||||
| | | | | |
|
||||
| Yannik Haupt | | | f4f597c57d8a31960750e0647f917ed3 | [y.haupt@tu-braunschweig.de](mailto:y.haupt@tu-braunschweig.de) |
|
||||
| Aurela Brahimi | | | 5ce6c08f9b055ca085232da514623ca4 | [a.brahimi@tu-braunschweig.de](mailto:a.brahimi@tu-braunschweig.de) |
|
||||
|
||||
# Notizen
|
||||
|
||||
|
@ -7,13 +7,13 @@ tags:
|
||||
---
|
||||
# Mitglieder
|
||||
|
||||
| Name | Punkte | Durchschnitt | Jupyter Kennung | Mail |
|
||||
| ----------------- | ------ | ------------ | --------------- | ----------------------------------------------------------------------------- |
|
||||
| Fabian Rothberger | | | | [f.rothberger@tu-braunschweig.de](mailto:f.rothberger@tu-braunschweig.de) |
|
||||
| Flemming Schur | | | | [flemming.schur@tu-braunschweig.de](mailto:flemming.schur@tu-braunschweig.de) |
|
||||
| Josefine Sinkemat | | | | [j.sinkemat@tu-braunschweig.de](mailto:j.sinkemat@tu-braunschweig.de) |
|
||||
| | | | | |
|
||||
| | | | | |
|
||||
| Name | Punkte | Durchschnitt | Jupyter Kennung | Mail |
|
||||
| ----------------- | ------ | ------------ | -------------------------------- | ----------------------------------------------------------------------------- |
|
||||
| Fabian Rothberger | | | | [f.rothberger@tu-braunschweig.de](mailto:f.rothberger@tu-braunschweig.de) |
|
||||
| Flemming Schur | | | df2b997f3ff3e1f7395fb071bb6c9f17 | [flemming.schur@tu-braunschweig.de](mailto:flemming.schur@tu-braunschweig.de) |
|
||||
| Josefine Sinkemat | | | | [j.sinkemat@tu-braunschweig.de](mailto:j.sinkemat@tu-braunschweig.de) |
|
||||
| | | | | |
|
||||
| | | | | |
|
||||
|
||||
# Notizen
|
||||
|
||||
|
@ -7,13 +7,13 @@ tags:
|
||||
---
|
||||
# Mitglieder
|
||||
|
||||
| Name | Punkte | Durchschnitt | Jupyter Kennung | Mail |
|
||||
| --------------- | ------ | ------------ | -------------------------------- | ----------------------------------------------------------------------- |
|
||||
| Nele Grundke | | | f61621cbe911f21ddd781c21e4528b07 | [n.grundke@tu-braunschweig.de](mailto:n.grundke@tu-braunschweig.de) |
|
||||
| Julia Limbach | | | | [j.limbach@tu-braunschweig.de](mailto:j.limbach@tu-braunschweig.de) |
|
||||
| Melina Sablotny | | | 4111400b4ae2c863a1c4b73a21f87093 | [m.sablotny@tu-braunschweig.de](mailto:m.sablotny@tu-braunschweig.de) |
|
||||
| Lucy Thiele | | | 4c0ddab5bed6ff025cee04f8d73301a3 | [lucy.thiele@tu-braunschweig.de](mailto:lucy.thiele@tu-braunschweig.de) |
|
||||
| | | | | |
|
||||
| Name | Punkte | Durchschnitt | Jupyter Kennung | Mail |
|
||||
| ---------------- | ------ | ------------ | -------------------------------- | ----------------------------------------------------------------------- |
|
||||
| Nele Grundke | | | f61621cbe911f21ddd781c21e4528b07 | [n.grundke@tu-braunschweig.de](mailto:n.grundke@tu-braunschweig.de) |
|
||||
| Julia Limbach | | | 2f7f31211275384791a1799cd95750bf | [j.limbach@tu-braunschweig.de](mailto:j.limbach@tu-braunschweig.de) |
|
||||
| Melina Sablotny | | | 4111400b4ae2c863a1c4b73a21f87093 | [m.sablotny@tu-braunschweig.de](mailto:m.sablotny@tu-braunschweig.de) |
|
||||
| Lucy Thiele | | | 4c0ddab5bed6ff025cee04f8d73301a3 | [lucy.thiele@tu-braunschweig.de](mailto:lucy.thiele@tu-braunschweig.de) |
|
||||
| Marleen, Adolphi | | | bb549f9016ee05a07ce271c10482879d | [m.adolphi@tu-braunschweig.de](mailto:m.adolphi@tu-braunschweig.de) |
|
||||
|
||||
# Notizen
|
||||
|
||||
|
@ -10,7 +10,7 @@ tags:
|
||||
| Name | Punkte | Durchschnitt | Jupyter Kennung | Mail |
|
||||
| ------------------- | ------ | ------------ | -------------------------------- | --------------------------------------------------------------------------------- |
|
||||
| Abdalaziz Abunjaila | 30.5 | | 79b388885f89954decaefc9e19aa8871 | [a.abunjaila@tu-braunschweig.de](mailto:a.abunjaila@tu-braunschweig.de) |
|
||||
| Marleen Adolphi | | | bb549f9016ee05a07ce271c10482879d | [m.adolphi@tu-braunschweig.de](mailto:m.adolphi@tu-braunschweig.de) |
|
||||
| | | | | |
|
||||
| Alea Schleier | | | beb3bcd7515400b58f6fab7567193cbf | [a.schleier@tu-braunschweig.de](mailto:a.schleier@tu-braunschweig.de) |
|
||||
| Marie Seeger | | | f7017b11a2904a74302c9f4f217779fb | [marie.seeger@tu-braunschweig.de](mailto:marie.seeger@tu-braunschweig.de) |
|
||||
| Lilly-Lu Warnken | | | 5fe894b59ff39da82ac4361dcb2d35b8 | [lilly-lu.warnken@tu-braunschweig.de](mailto:lilly-lu.warnken@tu-braunschweig.de) |
|
||||
|
@ -9,4 +9,347 @@ tags:
|
||||
|
||||
- [ ] Bernoulli Distributions
|
||||
- [ ] Binomial Distributions
|
||||
- [ ] Normal Distributions
|
||||
- [ ] Normal Distributions
|
||||
- [ ] Regression
|
||||
|
||||
## Aufgabe - Erster eigener Plot Square Root
|
||||
|
||||
Analog zu voheriger Erklärung plotten Sie im folgenden die Funktion Square Root, Mathematisch definiert als $f(x) = \sqrt x; \quad x \geq 0$.
|
||||
|
||||
Gehen Sie dabei wie folgt vor:
|
||||
|
||||
1. Definieren Sie einen **geeigneten** [Linespace](https://numpy.org/doc/stable/reference/generated/numpy.linspace.html#numpy-linspace) für die Zahlenraum 0...100. (Tipp: Achten Sie auf die Definition! Die Wurzel ist nur für positive Zahlen definiert.)
|
||||
2. Berechnen Sie mittels der Funktion [np.sqrt](https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html#numpy.sqrt) die Werte für die Wurzel.
|
||||
3. Plotten Sie das Ergebnis
|
||||
|
||||
```python
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# geeigneter Linespace für den Zahlenraum 0 bis 100
|
||||
x = np.linspace (0, 100, 500) # 500 Punkte für eine glatte Darstellung
|
||||
|
||||
# Berechnen der Wurzelfunktion
|
||||
y = np.sqrt(x)
|
||||
|
||||
# plotten der Ergebnisse
|
||||
plt.plot(x, y, label="f(x)= √x")
|
||||
plt.title("Plot der Wurzelfunktion")
|
||||
plt.xlabel("x")
|
||||
plt.ylabel("f(x)")
|
||||
plt.grid(True)
|
||||
plt.legend()
|
||||
plt.show()
|
||||
```
|
||||
Alea Schleier
|
||||
|
||||
|
||||
## Aufgabe[¶](https://jupyter2.ifn.ing.tu-bs.de:8000/user/instructor-einfhrung-in-die-prog/formgrader/submissions/14fa26f422cf4db2a97309e97b0bfdbd/?index=16#Aufgabe)
|
||||
|
||||
_6 Punkte_
|
||||
|
||||
Plote die Zufallszahlen eines _Permuted Congruent Generators_ mittels NumPy & MatPlotLib.
|
||||
|
||||
- Gegeben ist der Anfangszustand des Generators.
|
||||
- Nutze die Dokumentation und rufe den `default_rng` aus dem `numpy.random` Modul, **20** mal auf speichere die Werte in der variablen `pcgs`. _(Tipp: Nutze ein NumPy Array)_
|
||||
- Sortiere im nächsten Schritt die in `pcgs` gespeicherten Werte und speichere diese in `pcgs_sorted`
|
||||
- Plotte sinnvoll beide Array. Gestalte den Plot angemessen.
|
||||
|
||||
```python
|
||||
import numpy as np # Import NumPy
|
||||
import matplotlib.pyplot as plt # Import Matplotlib for plotting
|
||||
|
||||
# 1. Setting the random seed
|
||||
np.random.seed(42)
|
||||
|
||||
# 2. Generate 20 random numbers using the default_rng generator
|
||||
rng = np.random.default_rng() # Initialize the default random number generator
|
||||
pcgs = rng.random(20) # Generate 20 random numbers
|
||||
|
||||
# 3. Sort the generated numbers and store them in pcgs_sorted
|
||||
pcgs_sorted = np.sort(pcgs) # Sort the numbers
|
||||
|
||||
# 4. Print the generated arrays for verification
|
||||
print("PCGs:", pcgs)
|
||||
print("Sorted PCGs:", pcgs_sorted)
|
||||
|
||||
# 5. Plot both arrays
|
||||
plt.figure(figsize=(8, 6))
|
||||
plt.plot(pcgs, label='PCGs (Unsorted)', linestyle='dashed', marker='o')
|
||||
plt.plot(pcgs_sorted, label='PCGs (Sorted)', linestyle='solid', marker='x')
|
||||
plt.title('Permuted Congruent Generator: Unsorted vs Sorted')
|
||||
plt.xlabel('Index')
|
||||
plt.ylabel('Value')
|
||||
plt.legend()
|
||||
plt.grid(True)
|
||||
plt.show()
|
||||
```
|
||||
Abdalaziz Abunjaila
|
||||
|
||||
```python
|
||||
np.random.seed(42) # Setting a fixed start Value for the Generator
|
||||
pcgs: np.array = None
|
||||
pcgs_sorted: np.array = None
|
||||
|
||||
#mycode
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
rng = np.random.default_rng(seed=42)
|
||||
|
||||
pcgs = np.array([rng.random() for _ in range(20)])
|
||||
|
||||
pcgs_sorted = np.sort(pcgs)
|
||||
|
||||
plt.figure(figsize=(10, 5))
|
||||
|
||||
plt.plot(pcgs, label="PCG Zufallszahlen", color='blue', marker='o', linestyle='--')
|
||||
|
||||
plt.plot(pcgs_sorted, label="Sortierte PCG Zufallszahlen", color='green', marker='x', linestyle='-')
|
||||
|
||||
plt.title("PCG Zufallszahlen und sortierte PCG Zufallszahlen")
|
||||
plt.xlabel("Index")
|
||||
plt.ylabel("Wert")
|
||||
plt.legend()
|
||||
|
||||
plt.show()
|
||||
```
|
||||
Donika Nuhiu
|
||||
|
||||
```python
|
||||
np.random.seed(42) # Setting a fixed start Value for the Generator
|
||||
pcgs: np.array = None
|
||||
pcgs_sorted: np.array = None
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# Erstellen des Zufallsgenerators und Generation von 20 Zufallszahlen
|
||||
rng = np.random.default_rng() # Initialisiere den Permuted Congruent Generator
|
||||
pcgs = rng.random(20) # 20 Zufallszahlen erzeugen und in ein NumPy Array speichern
|
||||
|
||||
# Sortieren der Zufallszahlen
|
||||
pcgs_sorted = np.sort(pcgs)
|
||||
|
||||
# Plotten der Ergebnisse
|
||||
plt.figure(figsize=(10, 6))
|
||||
|
||||
# Original Zufallszahlen
|
||||
plt.plot(pcgs, marker='o', linestyle='-', color='blue', label='Original-Zufallszahlen')
|
||||
|
||||
# Sortierte Zufallszahlen
|
||||
plt.plot(pcgs_sorted, marker='x', linestyle='--', color='red', label='Sortierte Zufallszahlen')
|
||||
|
||||
# Gestalte den Plot
|
||||
plt.title("Vergleich: Original- und sortierte Zufallszahlen")
|
||||
plt.xlabel("Index")
|
||||
plt.ylabel("Zufallswert")
|
||||
plt.grid(True)
|
||||
plt.legend()
|
||||
|
||||
plt.show()
|
||||
```
|
||||
Alea Schleier
|
||||
|
||||
```python
|
||||
np.random.seed(42) # Setting a fixed start Value for the Generator
|
||||
pcgs: np.array = None
|
||||
pcgs_sorted: np.array = None
|
||||
|
||||
# YOUR CODE HERE
|
||||
rng = np.random.default_rng(42)
|
||||
pcgs = rng.random(20)
|
||||
pcgs_sorted = np.sort(pcgs)
|
||||
|
||||
x = np.linspace(0, 20, num=20)
|
||||
|
||||
plt.plot(x, pcgs, color='c', label='Zufallszahlen')
|
||||
plt.plot(x, pcgs_sorted, color='b', label='Zufallszahlen (sortiert)')
|
||||
|
||||
plt.title('Zufallszahlen eines PCG')
|
||||
plt.xlabel('Index')
|
||||
plt.ylabel('Wert')
|
||||
|
||||
plt.xlim(0, 20)
|
||||
plt.ylim(0, 1.25)
|
||||
plt.xticks(np.arange(0, 20, step=3))
|
||||
plt.yticks(np.arange(0, 1.25, step=0.2))
|
||||
|
||||
mean_value = np.mean(pcgs)
|
||||
plt.axhline(y=mean_value, color='r', linestyle="dashed", label=f'Durchschnitt: {mean_value:.2f}')
|
||||
|
||||
plt.legend()
|
||||
plt.show()
|
||||
```
|
||||
Nova Eib
|
||||
|
||||
```python
|
||||
np.random.seed(42) # Setting a fixed start Value for the Generator
|
||||
pcgs: np.array = None
|
||||
pcgs_sorted: np.array = None
|
||||
|
||||
# YOUR CODE HERE
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
rng = np.random.default_rng(seed=42)
|
||||
|
||||
pcgs = rng.random(20)
|
||||
|
||||
pcgs_sorted = np.sort(pcgs)
|
||||
|
||||
plt.figure(figsize=(10, 6))
|
||||
|
||||
plt.plot(pcgs, 'o-', label='Unsortiert')
|
||||
|
||||
plt.plot(pcgs_sorted, 's-', label='Sortiert')
|
||||
|
||||
plt.title('Zufallszahlen eines Permuted Congruent Generators')
|
||||
plt.xlabel('Index')
|
||||
plt.ylabel('Wert')
|
||||
plt.grid(True)
|
||||
plt.legend()
|
||||
|
||||
plt.show()
|
||||
```
|
||||
Izabel Mike
|
||||
|
||||
### Aufgabe[¶](https://jupyter2.ifn.ing.tu-bs.de:8000/user/instructor-einfhrung-in-die-prog/formgrader/submissions/f483499addec4dd8886a0ee278677732/?index=21#Aufgabe)
|
||||
|
||||
_5 Punkte_
|
||||
|
||||
Ihnen ist ein Datenset `sec_school` einer Hauptschule gegeben, welches die Klassenstufen von 5 bis 9 auf die Anzahl ihrer Schüler im Jahrgang mappt.
|
||||
|
||||
Definieren Sie einen Barplot. Gehen Sie dabei wie folgt vor:
|
||||
|
||||
1. Definieren Sie ein geeignetes Farbschema zur Darstellung der Daten.
|
||||
2. Extrahieren Sie die Schlüssel und Werte aus dem Datenset und übergeben Sie diese zusammen mit den Farbwerten an die Funktion `plt.bar`.
|
||||
3. Setzen Sie geeignete Werte für die X & Y-Achse.
|
||||
4. Setzen Sie einen geeigneten Titel für den Plot.
|
||||
5. Plotten Sie den Werte
|
||||
|
||||
```python
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
sec_school = {
|
||||
'5. Klasse': 29,
|
||||
'6. Klasse': 35,
|
||||
'7. Klasse': 25,
|
||||
'8. Klasse': 28,
|
||||
'9. Klasse': 31
|
||||
}
|
||||
|
||||
bar_colors = ["purple", "blue", "green", "orange", "red"]
|
||||
|
||||
plt.bar(sec_school.keys(), sec_school.values(), color=bar_colors)
|
||||
|
||||
plt.xlabel("Klassenstufen")
|
||||
plt.ylabel("Anzahl Schüler")
|
||||
plt.title("Anzahl der Schüler pro Klassenstufe in der Hauptschule")
|
||||
|
||||
plt.show()
|
||||
```
|
||||
Donika Nuhiu
|
||||
|
||||
```python
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
sec_school = {
|
||||
'5. Klasse': 29,
|
||||
'6. Klasse': 35,
|
||||
'7. Klasse': 25,
|
||||
'8. Klasse': 28,
|
||||
'9. Klasse': 31
|
||||
}
|
||||
|
||||
colors = ['blue', 'green', 'orange', 'purple', 'red']
|
||||
|
||||
grades = list(sec_school.keys()) # Klassenstufen
|
||||
students= list(sec_school.values()) # Schüleranzahl
|
||||
|
||||
plt.bar (grades, students, color=colors)
|
||||
|
||||
plt.xlabel("Klassenstufen")
|
||||
plt.ylabel("Anzahl der Schüler")
|
||||
|
||||
plt.title("Schüleranzahl pro Klassenstufe in der Hauptschule")
|
||||
|
||||
plt.grid(axis='y', linestyle='--', alpha=0.7) # Gitterlinie zur besseren Lesbarkeit
|
||||
plt.show()
|
||||
```
|
||||
Alea Schleier
|
||||
|
||||
```python
|
||||
bar_colors = ["red", "orangered", "darkorange", "orange", "gold"]
|
||||
|
||||
plt.bar(sec_school.keys(), sec_school.values(), color=bar_colors)
|
||||
|
||||
plt.title("Klassenverteilung (Hauptschule)")
|
||||
plt.ylabel("Anzahl Kinder")
|
||||
plt.xlabel("Klassenstufen")
|
||||
|
||||
# Ich finde die Werte der x- und y-Achse schon passend, also mach mich wenn dann für meine Fehleinschätzung und nicht für meinen Analphabetismus fertig, ich habe den Punkt gelesen, danke
|
||||
|
||||
mean_value = np.mean(list(sec_school.values()))
|
||||
plt.axhline(y=mean_value, color='blue', linestyle="dashed", label=f'Durchschnitt: {mean_value:.2f}')
|
||||
|
||||
plt.legend()
|
||||
plt.show()
|
||||
```
|
||||
Nova Eib
|
||||
## Aufgabe[¶](https://jupyter2.ifn.ing.tu-bs.de:8000/user/instructor-einfhrung-in-die-prog/formgrader/submissions/a02d96d8a5c8452b91ac790b5fb5ce9b/?index=24#Aufgabe)
|
||||
|
||||
_5 Punkte_
|
||||
|
||||
Ihnen ist ein Datenset `sec_school` einer Hauptschule gegeben, welches die Klassenstufen von 5 bis 9 auf die Anzahl ihrer Schüler im Jahrgang mappt.
|
||||
|
||||
Definieren Sie einen Pieplot. Gehen Sie dabei wie folgt vor:
|
||||
|
||||
1. Definieren Sie ein geeignetes Farbschema zur Darstellung der Daten.
|
||||
2. Extrahieren Sie die Schlüssel und Werte aus dem Datenset und übergeben Sie diese zusammen mit den Farbwerten an die Funktion `plt.pie`. (Nutzen Sie zum Anzeigen der Prozentwerte)
|
||||
3. Lassen Sie die 6. Klasse 25% und die 9. Klasse 40% explodieren.
|
||||
4. Setzen Sie einen geeigneten Titel für den Plot.
|
||||
5. Plotten Sie den Werte.
|
||||
|
||||
```python
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
#geeignetes Farbschema definieren, Kontrastreiche Farben zur einfachen Unterscheidung
|
||||
colors = ['#ff6f61', '#6b5b95', '#88b04b', '#f7cac9', '#92a8d1']
|
||||
|
||||
#extrahieren der Werte und Schlüssel
|
||||
keys = list (sec_school.keys())
|
||||
values = list (sec_school.values())
|
||||
|
||||
#explodieren der 6. und 9. Klassenstufe
|
||||
explode = [0, 0.25, 0, 0, 0.4]
|
||||
|
||||
plt.pie(values, labels = keys, colors = colors, autopct = '%1.1f%%', startangle = 90, explode = explode)
|
||||
plt.title ('Verteilung der Schüler*innen auf die unterschiedlichen Klassenstufen')
|
||||
plt.axis ('equal')
|
||||
|
||||
plt.show()
|
||||
```
|
||||
Lara Troschke
|
||||
|
||||
```python
|
||||
pie_colors = ["red", "orangered", "darkorange", "orange", "gold"]
|
||||
|
||||
plt.pie(sec_school.values(), labels=sec_school.keys(), autopct='%1.1f%%', explode=[0, 0.25, 0, 0, 0.4], colors=pie_colors)
|
||||
|
||||
plt.title("Klassenverteilung (Hauptschule)")
|
||||
|
||||
plt.show()
|
||||
```
|
||||
Nova Eib
|
||||
|
||||
```python
|
||||
pie_colors = ["lightpink", "darkseagreen", "mistyrose", "cadetblue", "rosybrown"]
|
||||
|
||||
plt.pie(sec_school.values(), labels=sec_school.keys(), autopct='%1.1f%%', explode=[0, 0.25, 0, 0, 0.4], colors=pie_colors)
|
||||
|
||||
plt.title("Klassenverteilung einer Hauptschule")
|
||||
|
||||
plt.show()
|
||||
```
|
||||
Julia Limbach
|
122
Material/Untitled.ipynb
Normal file
122
Material/Untitled.ipynb
Normal file
@ -0,0 +1,122 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "d74e7711-ed1a-4749-8827-2e6fa5798d68",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def lcg (a,c,m, startwert):\n",
|
||||
"\n",
|
||||
" if a<=0 or c<0 or m<=0 or startwert <0:\n",
|
||||
" return None #prüfung der werte \n",
|
||||
" \n",
|
||||
" x = startwert \n",
|
||||
" while 1:\n",
|
||||
" x=(a*x+c)%m\n",
|
||||
" yield x "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "2993ac89-2be8-4c61-a6e2-43a1008f2d36",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def lcg_test(seed: int, scalar: int, modulus: int, offset: int) -> int:\n",
|
||||
" assert modulus > 0, \"Modulus must be greater than 0\"\n",
|
||||
" assert 0 <= scalar and scalar < modulus, \"Scalar must be in range 0 <= a < m\"\n",
|
||||
"\n",
|
||||
" while seed > 1:\n",
|
||||
" seed = (scalar*seed+offset) % modulus\n",
|
||||
" assert seed >= 0\n",
|
||||
" yield seed"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"id": "02a21a6d-0892-44f0-b0fd-6e5f8fe83962",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Lcg using Cocktailshaker Numbers: 3089810780120156248\n",
|
||||
"Correct should be: 3089810780120156248\n",
|
||||
"\n",
|
||||
"Lcg using Cocktailshaker Numbers: 8356396685252565260\n",
|
||||
"Correct should be: 8356396685252565260\n",
|
||||
"\n",
|
||||
"Lcg using Cocktailshaker Numbers: 1921117399837525548\n",
|
||||
"Correct should be: 1921117399837525548\n",
|
||||
"\n",
|
||||
"Lcg using Cocktailshaker Numbers: 14806858147081821235\n",
|
||||
"Correct should be: 14806858147081821235\n",
|
||||
"\n",
|
||||
"Lcg using Cocktailshaker Numbers: 2557599628047639428\n",
|
||||
"Correct should be: 2557599628047639428\n",
|
||||
"\n",
|
||||
"Lcg using Cocktailshaker Numbers: 16453652254840064460\n",
|
||||
"Correct should be: 16453652254840064460\n",
|
||||
"\n",
|
||||
"Lcg using Cocktailshaker Numbers: 15995401842808378843\n",
|
||||
"Correct should be: 15995401842808378843\n",
|
||||
"\n",
|
||||
"Lcg using Cocktailshaker Numbers: 681272290641816305\n",
|
||||
"Correct should be: 681272290641816305\n",
|
||||
"\n",
|
||||
"Lcg using Cocktailshaker Numbers: 10955466795170118648\n",
|
||||
"Correct should be: 10955466795170118648\n",
|
||||
"\n",
|
||||
"Lcg using Cocktailshaker Numbers: 13714992071537968180\n",
|
||||
"Correct should be: 13714992071537968180\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"s = lcg(3203021881815356449, 11742185885288659963, 2**64-1, 3935559000370003845)\n",
|
||||
"t = lcg_test(3935559000370003845, 3203021881815356449, 2**64-1, 11742185885288659963)\n",
|
||||
"\n",
|
||||
"for _ in range(10):\n",
|
||||
" stud = next(s)\n",
|
||||
" instructor = next(t)\n",
|
||||
" print(\"Lcg using Cocktailshaker Numbers:\", stud)\n",
|
||||
" print(\"Correct should be:\", instructor, end='\\n\\n')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "40aeb297-aeb5-4fca-8ae4-cb84c7f13957",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.7"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
@ -1707,13 +1707,13 @@
|
||||
"id": "a2fbf6d5-9460-48bc-8183-b2afb9c5c186",
|
||||
"metadata": {
|
||||
"nbgrader": {
|
||||
"grade": false,
|
||||
"grade": true,
|
||||
"grade_id": "cell-9e88f0a0a4a77c47",
|
||||
"locked": true,
|
||||
"locked": false,
|
||||
"points": 3,
|
||||
"schema_version": 3,
|
||||
"solution": false,
|
||||
"task": true
|
||||
"solution": true,
|
||||
"task": false
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@ -2784,7 +2784,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.5"
|
||||
"version": "3.12.7"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
1230
Material/wise_24_25/lernmaterial/5.SciPy.ipynb
Normal file
1230
Material/wise_24_25/lernmaterial/5.SciPy.ipynb
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user