Starting from:

$24.99

CSE101 Lab 4 – Lists and loops Vector and matrix manipulation Solution



Today, we will address two topics:
1. Dot product computation
2. Matrix averaging









π‘Ž = π‘Žπ‘₯ π‘Žπ‘¦ π‘Žπ‘§
𝑏 = 𝑏π‘₯ 𝑏𝑦 𝑏𝑧
π‘Ž. 𝑏 cos πœƒ = π‘Ž 𝑏
Let’s solve it in three steps
1. Compute the magnitude π‘Ž and 𝑏 of both vectors π‘Ž = π‘Žπ‘₯2 + π‘Žπ‘¦2 + π‘Žπ‘§2 In magnitude(a, b)
2. Compute the dot product between the vectors π‘Ž. 𝑏 In dot(a, b)
3. Compute the cosine distance (angle πœƒ) with θ = π‘Žπ‘π‘œπ‘  π‘Žπ‘Ž.𝑏𝑏 In cos_distance(a, b)
Use acos from the module math!

Task 2: Matrix averaging

1. Numerical stability: Normalizing matrices can prevent numerical errors when performing operations such as inversion, eigenvalue calculation, and matrix decomposition.
2. Comparability: Normalizing matrices can make it easier to compare them.
3. Regularization: Normalizing matrices can help prevent overfitting in machine learning models.
4. Preprocessing: Normalizing matrices is often an important preprocessing step in machine learning to improve performance.

More products