Search for question
Question

COMP 3006 Homework 9 - Numpy General Homework Guidelines: Homework must be submitted in a .py file. Please do not submit .ipynb files. Homework should not use packages or functions that have not yet been discussed in class. Use comments to explain what your code is doing. Use a consistent coding style. Use descriptive variable names. Test your code regularly using a variety of different inputs. Every function must include a docstring for documentation (see: https://realpython.com/documenting-python-code/). - 1 or 2 lines describing what the function does This docstring should include: Args: input parameters, their types and what they are for Returns: return data type and what it is All tests of your functions should be commented out in your final submission or encolosed with an if name == '__main___' codeblock. - All functions should use return statements to return a value, rather than printing some value, unless the instructions specifically say to print. # Assignment 9.1 # Create a class, called Distributions, that has the following attributes: distribution, mean, standard deviation and size. # It should have a constructor, _str_ # based on the distribution attribute. # For example: method and the ability to generate a normal distribution, lognormal and laplace distributions #my_distribution = Distributions (dist="lognormal", mean=1, std=5, samples=100000) # should be a lognormal distribution with a mean of 1, standard deviation of 5 and have 100000 samples from the distribution # Assignment 9.2: # Repeat the first part, this time calling the class NumpyDistribution, using only numpy methods # Hint: https://numpy.org/doc/1.22/, you may want to looks at using args and kwargs # Assignment 9.3: # Use only methods from numpy and matplotlib. # Display the plot of one period of both the cosine and sine. They should appear on the same axes. Label the axes and the plot. Provide a grid. # Display the plot of one period of both the cosine and sine. They should appear on the different axes but share the y-axis. Label the axes and the plot. Provide a grid # Display the plot of one period of both the cosine and sine. They should appear on the different axes but share the x-axis. Label the axes and the plot. Provide a grid # Assignment 9.4: # In a separate file, test_homework9.py, write the necessary unittests for questions 9.1 and 9.2. Take careful consideration to # test valid and invalid values for the creation of any of the distributions./n

Fig: 1

Fig: 2