List if a distribution is continuous or discrete, its support, and an example of a random variable which follows the distribution. 1 Bonus point per problem for identifying a rv related to chemical engineering.
Using this sentence: "The quick brown fox jumps over the lazy dog", 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
In [2]:
#2.1
string = 'The quick brown fox jumps over the lazy dog'
print string[0]
for
loop, sum all the elements in the array and print the sum. Check your answer using the numpy sum
function.lambda
is a reserved word in python, meaning you cannot use it for a variable name. You can tell if a variable is reserved because it is a different color/font than other variables in ipython. Also, when applying mathematical functions to numpy arrays, you must use the numpy versions, for example numpy.cos
instead of math.cos
for
loop and the array from Question 3.1, compute the expected value of the exponential distribution. To evaluate the integral, use $\int f(x)dx = \sum_i f(x_i) \Delta x$, where $\Delta x$ is the spacing between your points and $f(x_i)$ is the function evaluated at point $x_i$. As you know, it should be $1/3$.sum
function from numpy, compute the expected value without a for
loop. from scipy.special import comb
and use the comb(N, n)
function, where n
is your array.
In [ ]: