Lesson 14
In [ ]:
# Setup: Reproducible random numbers
import numpy as np
rs = np.random.RandomState(20000101)
Problem: Basic Logical Statements¶
Create the variables (in order)
xasrs.random_sample(), a uniform on $[0, 1)$yasrs.standard_normal(), a standard normal ($N(0,1)$)zasrs.randint(1, 11), a uniform random integer on $[1, 2,\ldots, 10]$
Check whether each of these are above their expected value.
In [ ]:
In [ ]:
Problem: Using comparison operators¶
- Check if
zis 7 - Check is
zis not 5 - Check if
zis greater than or equal to 9
In [ ]:
Problem: Combining booleans¶
- Determine if $2\leq z < 8$
- Determine if $z < 2 \cup z \geq 8$ using
or - Rewrite 2 using
notand your result from 1.
In [ ]:
Exercises¶
In [ ]:
# Setup: Data for Exercise
import numpy as np
rs = np.random.RandomState(19991213)
# Like range, lower included, upper excluded
# u in (0, 1, 2, ..., 5)
u = rs.randint(0, 6)
# v in (-2, -1, 0, 1, 2)
v = rs.randint(-2, 3)
In [ ]:
Exercise¶
Is the product $uv$ 0 and only one of $u$ and $v$ is 0?
In [ ]:
In [ ]:
Exercise¶
Write three logical statements that will determine if $0\leq u \leq 2$ and $0\leq v \leq 2$.
In [ ]:
In [ ]:
In [ ]: