$\DeclareMathOperator{\P}{P}$ $\DeclareMathOperator{\E}{E}$
Answer the following problems in Python
Is $3^{14}$ greater than $10^6$?
Using the frexp
function, show how the floating point number $0.4$ is represented and rebuild the number from its pieces. Use base 10
Is $0.4 + 0.2$ exactly equal to $(4.0 + 2.0) / 10.0$ with floats? Why or why not?
The next cell contains a joint probability mass function for $x$ and $y$. $x$ is the first number and $y$ is the second. You may access elements like this: P[0,2]
. P[0,2]
is the probability that $x=0$ and $y=2$. Demonstrate that the two random variables are not independent.
Calculate the marginal $\P(x=2)$, where $x$ is the first index using the next cell's joint probability mass function.
Calculate the conditional $\P(x=2 | y = 1)$, where $x$ is the first index using the next cell's joint probability mass function.
In [3]:
#This is loading the data for question 1.4 through 1.6
#Execute this cell and use new cells below. Do not answer in this cell!
import numpy as np
P = np.zeros( (3,3) )
P[0,0] = 0.
P[0,1] = 1. / 9
P[0,2] = 1. / 9.
P[1,0] = 1. / 3
P[1,1] = 0.
P[1,2] = 1. / 9
P[2,0] = 1. / 18
P[2,1] = 1. / 9
P[2,2] = 1. / 6
Using this sentence: "This pangram contains four As, one B, two Cs, one D, thirty Es, six Fs, five Gs, seven Hs, eleven Is, one J, one K, two Ls, two Ms, eighteen Ns, fifteen Os, two Ps, one Q, five Rs, twenty-seven Ss, eighteen Ts, two Us, seven Vs, eight Ws, two Xs, three Ys, & one Z", Create slices of the string to answer the following questions. Note that character/element mean the same thing, so that every element in the sentence is a character. Answer in Python
for
loop, compute $10!$. for
loop compute $$\sum_{n=0}^{25}\frac{1}{n!}$$ What famous number is that?
In [ ]: