Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PYTHON Prob. 7W rite a function for the following tasks: a) Use numpy to generate a random array x = (z1,T2, . . . ,xn)
PYTHON
Prob. 7W rite a function for the following tasks: a) Use numpy to generate a random array x = (z1,T2, . . . ,xn) of length n, where xi's are drawn from normal distribution with mean and standard deviation . (This should be easily done using numpy b) Compute the 1-norm and 2-norm of the x generated in 7a) in a vectorized manner, i.e., ,xn), the 1-norm and 2-norm are without using loop. As a reminder, for x = (21,x2, defined, respectively, as c) Using the same x generated in 7a), compute sal = where x=- Use both a loop (save the value in sd11) and a vectorized operation (save the value in sd12) d) Using the same x generated in 7a), compute sd2 (zi-3)2 Tm Use both a loop (save the value in sd21) and a vectorized operation (save the value in sd22) The interface of your code is the following, where the mean and deviation are made keyword arguments with given default values 1 def stat_comp(n, mean- 1000, deviation 0.32): fill in the gap to fulfill the above listed tasks, return the answers in 3 a tuple (x, norml, norm2, sd11, sd12, sd21, sd22)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started