Skip to content

Commit

Permalink
log vector programming
Browse files Browse the repository at this point in the history
log vector tasks programming
  • Loading branch information
darya-malo committed Dec 22, 2024
1 parent 4d779ab commit 235364a
Show file tree
Hide file tree
Showing 4 changed files with 475 additions and 6 deletions.
358 changes: 358 additions & 0 deletions Math/linear_algebra/lecture1.ipynb

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions Math/linear_algebra/lecture1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"""Vectors.
Python programming.
"""

# mypy: allow-untyped-defs
# mypy: allow-untyped-calls
import numpy as np

# ![image.png](attachment:image.png)

# L2 norm
# Euclidean distance
#
#
# ![image.png](attachment:image.png)

vc = np.array([1, 2, 3, 7, 8, 9])
VC_DIM = len(vc)
vc_mag = np.linalg.norm(vc)


def norm_of_vector(vt):
"""Return a norm of a vector."""
return np.sqrt(np.sum(vt**2))


norm_of_vector(vc)

vc_mag # для сравнения с norm_of_vector

# ![image.png](attachment:image.png)

# ![image.png](attachment:image.png)

# w_unit = np.array([0, 1, 0])
wt = np.array([1, 3, 0])


def vector_to_unit_vector(vt):
"""Return a vector to unit vector."""
norm_of_vector2 = np.linalg.norm(vt)
return vt / norm_of_vector2


vector_to_unit_vector(wt)

vector_to_unit_vector(np.zeros((4, 1))) # error


# ![image.png](attachment:image.png)


def mag_vector(vct, mag):
"""Return a vector in the same direction with a magnitude."""
norm = norm_of_vector(vct)
return mag * vct / norm


wt = np.array([1, 0, 0])
mag_vector(wt, 2)

data = [1.72, 54, 36.2]
# type(data)

data_numpy = np.array(data)

data_matrix = np.array([[1.72, 54, 36.2], [1.74, 58, 36.3], [1.68, 52, 32.9]])

data_matrix # визуализация матрицы

data_matrix.shape
28 changes: 25 additions & 3 deletions log.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@
"\"\"\"Логирование уроков.\"\"\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<font size=\"5\">\n",
"22/12/2024 Linear algebra\n",
"</font>\n",
"\n",
"Python programming:\n",
"\n",
"1. The norm of vector\n",
"\n",
"2. A vector to unit vector transformation\n",
"\n",
"3. Zeros vector to unit vector transformation impossibility\n",
"\n",
"4. Creation of a vector of any arbitrary magnitude\n",
"\n",
"Dot product as optimization task"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -51,7 +72,8 @@
"\n",
"4. Attribute and method in Python class\n",
"\n",
"5. Vector addition and subtraction peculiarities (including -1 multiplication)\n",
"5. Vector addition and subtraction peculiarities (including -1\n",
"multiplication)\n",
"\n",
"6. Algebraic and geometric vector interpretation\n",
"\n",
Expand Down Expand Up @@ -153,8 +175,8 @@
"\n",
"12. Отношение функций и их степеней в пределе (бесконечность, 0, k, 1)\n",
"\n",
"13. Методы избавления от неопределенностей разного вида. Непрерывность функции\n",
"и ее доказательство\n",
"13. Методы избавления от неопределенностей разного вида. Непрерывность\n",
"функции и ее доказательство\n",
"\n",
"14. Точки разрыва (род и тип)\n",
"\n",
Expand Down
23 changes: 20 additions & 3 deletions log.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
"""Логирование уроков."""

# <font size="5">
# 22/12/2024 Linear algebra
# </font>
#
# Python programming:
#
# 1. The norm of vector
#
# 2. A vector to unit vector transformation
#
# 3. Zeros vector to unit vector transformation impossibility
#
# 4. Creation of a vector of any arbitrary magnitude
#
# Dot product as optimization task

# <font size="5">
# 17/12/2024 Linear algebra
# </font>
Expand Down Expand Up @@ -33,7 +49,8 @@
#
# 4. Attribute and method in Python class
#
# 5. Vector addition and subtraction peculiarities (including -1 multiplication)
# 5. Vector addition and subtraction peculiarities (including -1
# multiplication)
#
# 6. Algebraic and geometric vector interpretation
#
Expand Down Expand Up @@ -120,8 +137,8 @@
#
# 12. Отношение функций и их степеней в пределе (бесконечность, 0, k, 1)
#
# 13. Методы избавления от неопределенностей разного вида. Непрерывность функции
# и ее доказательство
# 13. Методы избавления от неопределенностей разного вида. Непрерывность
# функции и ее доказательство
#
# 14. Точки разрыва (род и тип)
#
Expand Down

0 comments on commit 235364a

Please sign in to comment.