Question: Write a python function to perform the following tasks: Set the seed of the numpy random number generator to 1 2 3 4 . Define
Write a python function to perform the following tasks:
Set the seed of the numpy random number generator to
Define
to be a
matrix with normally distributed random entries having zero mean and unit variance use numpy.random.normal
Loop through each element of
remember that there are two dimensions If the element is negative, make it positive by replacing it with its square ie set
to
if
But don't change the positive entries of
Use for and if Could you perform the same operation using only one line of code in python?
Now define
to be a
column vector of uniformly distributed numbers between and using numpy.random.uniform
Now define the
vector
using matrixvector product
Define
to be the mean value of the elementwise product between
and
ie the average over
of
You should be able to do this in one line. Use the builtin function, numpy.mean, to take the mean.
Run the script.
Debug any errors you see.
You should get a single positive number as the result. Please report your code and show a printout of the result.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
