Introduction#

  • Learning by doing and explaining

  • Writing a technical blog is a valuable skill.

  • Blog is like a resume only better

Why study Linear Algebra?#

Note

KEY QUESTION :-

How can we do matrix multiplication with acceptable speed and acceptable accuracy?

QUESTIONS :-

How computers(finite & discrete) store numbers (infinite & continuous)?

When designing algorithms for matrix multiplications we often have to tradeoff between :-

  • Memory Use

  • Speed (Approximate matrix computation may be 1000 times faster than actual one)

  • Accuracy

  • Scalability/ Parallelization

Types of Matrix Computations#

  • Matrix & Tensor products

  • Matrix decomposition

Topics to be covered#

  • Topic Modelling

  • Background Removal

  • Google PageRank Algorithm

  • Matrix Factorization Jungle

Lesson#1 Why are we here?

Imports#

import numpy as np
current_healthstate = np.array([[0.85], #asymptotic
                                [0.10], #symptotic
                                [0.5],  #aids
                                [0.0]]) #death
# current_healthstate[np.newaxis,]

transition matrix for 1 year

#            asymptotic symptotic aids death
# asymptotic
# symptotic
# aids
# death

transition_matrix = np.array([[0.9, 0.07, 0.03, 0.01],
                              [0.0, 0.93, 0.05, 0.02],
                              [0.0, 0.00, 0.85, 0.15],
                              [0.0, 0.00, 0.00, 1.00]])
transition_matrix
array([[0.9 , 0.07, 0.03, 0.01],
       [0.  , 0.93, 0.05, 0.02],
       [0.  , 0.  , 0.85, 0.15],
       [0.  , 0.  , 0.  , 1.  ]])
next_state = current_healthstate.T@transition_matrix; next_state
# This answer seems incorrect
array([[0.765 , 0.1525, 0.4555, 0.0855]])
transition_matrix = np.array([[6, 5, 3, 1],
                              [3, 6, 2, 2],
                              [3, 4, 3, 1]])

inp_matrix = np.array([[1.5, 1],
                      [2, 2.5],
                      [5, 4.5],
                      [16., 17.]])

transition_matrix@inp_matrix
array([[50. , 49. ],
       [58.5, 61. ],
       [43.5, 43.5]])

Greenbaum & Chartier#

def f(x):
    if x <= 1/2:
        return 2 * x
    if x > 1/2:
        return 2*x - 1
x = 1/10
for i in range(80):
    print(x)
    x = f(x)
0.1
0.2
0.4
0.8
0.6000000000000001
0.20000000000000018
0.40000000000000036
0.8000000000000007
0.6000000000000014
0.20000000000000284
0.4000000000000057
0.8000000000000114
0.6000000000000227
0.20000000000004547
0.40000000000009095
0.8000000000001819
0.6000000000003638
0.2000000000007276
0.4000000000014552
0.8000000000029104
0.6000000000058208
0.20000000001164153
0.40000000002328306
0.8000000000465661
0.6000000000931323
0.20000000018626451
0.40000000037252903
0.8000000007450581
0.6000000014901161
0.20000000298023224
0.4000000059604645
0.800000011920929
0.6000000238418579
0.20000004768371582
0.40000009536743164
0.8000001907348633
0.6000003814697266
0.20000076293945312
0.40000152587890625
0.8000030517578125
0.600006103515625
0.20001220703125
0.4000244140625
0.800048828125
0.60009765625
0.2001953125
0.400390625
0.80078125
0.6015625
0.203125
0.40625
0.8125
0.625
0.25
0.5
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0