Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Week 02 - List And Loops
LS30A LAB 1B/1D
TA: Hao Lee
LA: Evelyn Malamut
Review
Continuous Time System
What is the difference between R' and R?
What is a, b, c, d, e, f?
Ans:
R is a state variable, R' is the rate of change
a, e can be per-captia rate or proportionality, b and d are mostly proportionality, and c and f can be constant growth rate.
Nomenclature
Per-captia rate: increase/ decrease rate per unit of itself.
Proportionality: increase/ decrease rate related to anything.
e.g.,
R's growth rate is proportional to its own population, with proportionality a
R's per-captia growth rate is a
R's growth rate is proportional to J, with proportionality b
R has a constant growth rate c
Programming
Type of Data
Variables have data types
This makes no sense
Reason: They have different data types
Data Types of Variables
List
Put multiple variables together
It does not need to be the same data type
How can we retrieve variables from a list?
=> Indexing
How Indexing Works?
If starts from the beginning, index starts from 0
If starts from the end, index starts from -1
Example
We can retrieve more than one element!
Be careful, for index range 1:4, only elements at position 1,2,3 are retrieved.
Add components into a list
Plot of List
Currently we have learned plot
For most data set, we do not have the function!
Example: For a data set (x1,x2,x3,x4.......,xn),(y1,y2,y3,y4,........yn), please find their relationship!
X= (1,2,3,4,5)
Y= (1,4,9,16,25)
(,) IS ANNONYING
Connect all the points
Loops
Whatis loops for?
=> Doing Repeated Task for Different Things
Create list in a Loop
This is very useful when we are trying to do the following operation
We want to record the results
e.g., Do square root to [1,2,3,4,5,6,7]
Animation
What animation does?
Create a list of plots and plot them!!!!!