== Befehle #table(columns: (0.3fr, 1fr, 0.4fr), [Befehl], [Code], [Ausgabe], [Betrag], [```py np.abs(-5) ``` \ ```py np.absolute(-5) ```], [5], [Mittelwert], [```py np.mean([1, 2, 3, 4, 5]) ```], [3], [Median \ (Zentralwert)], [```py np.median([1, 2, 4, 5, 15]) ``` \ ```py np.median([1, 2, 4, 5, 15, 16]) ```], [4 \ 4.5], [Standardabweichung], [```py np.std([1, 2, 3, 4, 5]) ``` \ ```py np.std([1, 2, 3, 4, 5], ddof=1) ``` \ ddof = Delta Degrees of Freedom (Nicht so relevant für uns "höhere mathe" wichitg immer gleich machen!)], [1.41 \ 1.58], [Wurzel], [```py np.sqrt(16) ```], [4], [Integrall], [```py inter = np.trapezoid(y_data, x_data)```], [], [Array], [```py np.linspace(2, 10, 5) ```], [\[ 2. 4. 6. 8. 10.\]], [Array], [```py np.arange(4, 10) ``` \ ```py np.arange(0, 1, 0.2) ```], [\[4 5 6 7 8 9\] \ \[0. 0.2 0.4 0.6 0.8\]], [ln], [```py np.log(x) ```], [], [10er log], [```py np.log10(x) ```], [], ) == Matrizen #table(columns: (0.3fr, 0.9fr, 0.5fr), [Array], [```py A = np.array([[1, 3, -1], [4, -2, 8]]) B = np.array([[-3, 9, 3], [-6, 6, 3]]) ```],[], [Addition], [```py C = A + B ```],[``` C = [[-2 12 2] [-2 4 11]] ```], [Multiplikation], [```py C = A @ B D = -2 * B ```],[``` C = [[ 15 -3 24] [-52 92 -2]] D = [[ 6 -18 -6] [ -8 4 -16] [ 12 -12 -6]] ```], [Transposition], [```py C = A.T ```],[``` C = [[ 1 8] [ 3 -4] [-1 2]] ```], [Inverse], [```py C = np.linalg.inv(B) ```],[``` ```], [Rodrigues-Rotationsmatrizen], [```py def J(w): M = np.array([[0, -w[2], w[1]], [w[2], 0, -w[0]], [-w[1], w[0], 0]]) return M def R(phi, n): nn = n/np.linalg.norm(n) M = np.eye(3) + (1-np.cos(phi)) * J(nn)@J(nn) + np.sin(phi)*J(nn) return M ```],[``` ```], [Spur / trace], [```py s = np.trace(A) ```],[``` s = -3 ```], [Determinante], [```py d = np.linalg.det(A) ```],[``` ```], [], [], [\ ], [Zeros], [```py A = np.zeros((2,3)) ```],[``` [[0. 0. 0.] [0. 0. 0.]] ```], [Ones], [```py A = np.ones((2,3)) ```],[``` [[1. 1. 1.] [1. 1. 1.]] ```], [Eye], [```py A = np.eye(2,3) ```],[``` [[1. 0. 0.] [0. 1. 0.]] ```], [Diag], [```py d = np.array([1.,2.,3.]) A = np.diag(d) ```],[``` [[1. 0. 0.] [0. 2. 0.] [0. 0. 3.]] ```], [Diag rev.], [```py A = np.array([[1. 0. 0.], [0. 2. 0.], [0. 0. 3.]] B = np.diag(A) ```],[``` B = [1. 2. 3.] ```], ) == Matplotlib #table(columns: (0.3fr, 0.9fr, 0.5fr), [Linien], [```py x = [1, 2, 3, 4] y = [1, 4, 9, 16] plt.plot(x, y) plt.xlabel('Zeit (s)') plt.ylabel('Amplitude') plt.grid() plt.show() ```], [#image("../img/python/matplotlib_linie.png", width: 100%)], [Kreis], [```py labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' sizes = [15, 30, 45, 10] plt.pie(sizes, labels=labels) plt.show() ```], [#image("../img/python/matplotlib_kreis.png", width: 100%)], [Punktwolke / Scatterplot], [```py n = 100 x = np.random.normal(0,1,n) y = np.random.normal(0,1,n) plt.scatter(x, y) plt.title('Scatter Plot') plt.xlabel('x') plt.ylabel('y') plt.show() ```], [#image("../img/python/matplotlib_punktewolke.png", width: 100%)], [Säulendiagramme], [```py fruits = ['apple', 'blueberry', 'cherry', 'orange'] counts = [40, 100, 30, 55] bar_labels = ['red', 'blue', '_red', 'orange'] bar_colors = ['tab:red', 'tab:blue', 'tab:red', 'tab:orange'] plt.bar(fruits, counts, label=bar_labels, color=bar_colors) plt.ylabel('fruit supply') plt.title('Fruit supply by kind and color') plt.show() ```], [#image("../img/python/matplotlib_säulendiagramme.png", width: 100%)], [Säulendiagramme wagerecht], [```py fruits = ['apple', 'blueberry', 'cherry', 'orange'] counts = [40, 100, 30, 55] bar_labels = ['red', 'blue', '_red', 'orange'] bar_colors = ['tab:red', 'tab:blue', 'tab:red', 'tab:orange'] plt.barh(fruits, counts, label=bar_labels, color=bar_colors) plt.ylabel('fruit supply') plt.title('Fruit supply by kind and color') plt.show() ```], [#image("../img/python/matplotlib_säulendiagramme_wagerecht.png", width: 100%)], [Ausgabe als png], [```py plt.savefig("test.png", transparent=True) # transparent nur für png plt.savefig("test.png") plt.show() # savefig muss zwingend vor show()! ```], [#image("../img/python/matplotlib_savefig.png", width: 100%)], [Ausgabe als pdf], [```py plt.savefig("test.pdf", pad_inches=0.1, bbox_inches="tight") # so ist der Rand um den plot schmaller. plt.savefig("test.pdf") plt.show() # savefig muss zwingend vor show()! ```], [#image("../img/python/matplotlib_savefig_tight.png", width: 100%)], [Ausgabe als svg], [```py plt.savefig("test.svg") plt.show() # savefig muss zwingend vor show()! ```], [svg ist eine Vektorgrafik], )