vectors
Mathematical Programming with Python
https://people.sc.fsu.edu/~jburkardt/classes/...
python_2025/vectors/vectors.html
vectors:
how the vectors of linear algebra can be
created, modified, analyzed, and indexed, using the numpy() library.
Lecture notes:
-
basketball_scores.py,
counts the number of ways of getting each basketball score between
0 and 20. A dynamic approach looks at the most recently
made point. One algorithm considers each point separately;
another uses a logical multiplier to create a one-line formula.
-
football_scores.py,
counts the number of ways of getting each football score between
0 and n points. A logical condition like (1 <= i) is used as
a multiplier so that the formula can be written as a single line.
-
in_circle.py,
demonstrates the use of conditional indexing for numpy vectors.
We compute the distance of every point from the center.
Then we can choose only the points inside the circle,
and show them as blue dots, and choose points outside the circle
to be shown in red.
-
random_normal.py,
computes 10,000 normal random values 3 times.
The first and last times, we use the same seed, and get the
same results. The numpy functions min(), mean(), max(),
std(), var() are demonstrated. The last set of values is also shown as
a histogram.
-
sawtooth.py,
evaluates a Fourier approximation to the sawtooth function.
The value at many points can be computed with a single command,
because the input is a numpy array.
-
triangle_distance.py,
analyzes the typical distance between random points in a
3/4/5 triangle. It uses numpy functions sqrt(), sum(),
max() and where().
Last revised on 31 January 2025.