Describe similarities and differences between numpy

Assignment Help Business Management
Reference no: EM132203062

Part A) Arrays and copy semantics Consider the following Python code segment, which uses built-in Python lists and NumPy lists to perform similar operations, albeit with differing results.

Using built-in Python lists:

>>> data = [1, 2, 3, 4]

>>> print data [1, 2, 3, 4]

>>> otherData = data

>>> otherData[1] = -2

>>> print otherData [1, -2, 3, 4]

>>> print data [1, -2, 3, 4]

>>>

>>> otherData = data[1:3]

>>> print otherData [-2, 3]

>>> otherData[0] = 0

>>> print otherData [0, 3]

>>> print data Using NumPy arrays:

>>> import numpy as np

>>> data = np.array([1, 2, 3, 4])

>>> print data [1 2 3 4]

>>> otherData = data

>>> otherData[1] = -2

>>> print otherData [1 -2 3 4]

>>> print data [1 -2 3 4]

>>>

>>> otherData = data[1:3]

>>> print otherData [-2 3]

>>> otherData[0] = 0

>>> print otherData [0 3]

>>> print data [1 0 3 4]

Describe similarities and differences between copying and assignment semantics of built-in Python lists and NumPy arrays. Explain why the code behaves differently for the two.

Part B) Matrices NumPy also supports matrices. However, there are some important differences between two-dimensional arrays and matrices. Consider the following two code segments that are similar, but produce different results: Using NumPy two-dimensional arrays:

>>> A = np.array([[1,2], [3,4]])

>>> B = np.array([[2,1], [-1,2]])

>>> A * B array([[ 2, 2], [-3, 8]])

>>> A ** 3 array([[ 1, 8], [27, 64]])

Using NumPy matrices:

>>> A = np.matrix([[1,2], [3,4]])

>>> B = np.matrix([[2,1], [-1,2]])

>>> A * B matrix([[ 0, 5], [ 2, 11]])

>>> A**3 matrix([[ 37, 54], [ 81, 118]])

Describe similarities and differences between NumPy two-dimensional arrays and matrices. Explain why the code behaves differently for the two.

Reference no: EM132203062

Questions Cloud

How does bitcoin cash prevent replay attacks : MN504 - Networked Application Management - Cryptocurrency giants-Litecoin and Bitcoin Cash - Perform a literature review on modern network applications
What is your perspective on behavioral bias : What is your perspective on behavioral bias? Discuss an economic decision you have made based on behavioral bias rather than rational decision-making.
Comparative advantage in the production of specific items : You are getting ready to open The Shoe Hut, but you need to need to determine whether you have the absolute or comparative advantage in the production
Stores data in hexadecimal format : The RAM of the a computer stores data in Hexadecimal format. Is this correct?
Describe similarities and differences between numpy : Describe similarities and differences between NumPy two-dimensional arrays and matrices. Explain why the code behaves differently for the two.
Describe similarities and differences between numpy : Describe similarities and differences between NumPy two-dimensional arrays and matrices. Explain why the code behaves differently for the two.
Which functional dependency causes bcnf violation : List candidate key(s), and how you found the key(s). Which functional dependency causes BCNF violation? Decompose T1 into BCNF tables. Please show all work he
Briefly discuss the needs for virtual memory : Topic 1: Briefly discuss the needs for virtual memory. Topic 2: Briefly discuss how virtual memory works.
Main objective of cloud computing : What is the main objective of Cloud Computing?

Reviews

Write a Review

Business Management Questions & Answers

  Evaluating the impact of health care law on health care

Select a health care law that is either previously in effect or under consideration. Using APA format, make a minimum 10 slide power point presentation evaluating the impact of this law on health care

  Illustrate what are the implications for when jacob

According to your model, when will top slice need to have the expanded work cell up also running. Illustrate what are the implications for when Jacob should start the expansion effort.

  How do you know if a website is credible

How do you know if a website is credible? In a short 3-5 sentence paragraph explain what makes a website more credible (and thus, more useful for formal academic and job-place writing).

  Complexities in leadership

At your hospital, the Committee on Medical Ethics is a medical staff committee. It answers to the Medical Executive Committee and the medical staff president.

  Manager of operations at longtech

You are the newly promoted Manager of Operations at LongTech, Inc., an international communications company that manufactures, integrates, and installs communication equipment in terrestrial stations around the world.

  Capacity to adapt to changing circumstances

Assertion (A): A bureaucrat's capacity to adapt to changing circumstances is far less than that conceived by those who drew up the organizational rules. Reason (R): In order to be perceived as effective, the bureaucrat behaves consistently and fol..

  Which of the following is a false statement regarding

Jacob files a lawsuit against both Perfect and Green's. Which of the following is a FALSE statement regarding the lawsuit?

  Prepare a paper examining a business problem

Prepare a paper examining a business problem confronting your organization or an organization you know of that you feel could be addressed through the application of the business research process.

  Harvard liverpool referencing system

Select two competing brands (international brand - e.g. samsung vs apple) in a product category and evaluate each brand's packaging based on the VIEW model.

  Conclude the margin of error that would be used to estimate

Conclude the margin of error that would be used to estimate the slope for a least squares simple linear regression model if the standard error simple regression estimator for the standard deviation of the slope

  Customers of the firms and not the employers themselves

How does your answer change if the agents who indulge their taste to discriminate are customers of the firms and not the employers themselves?

  What kind of strategy would you recommend

What kind of strategy would you recommend if Roy Choi decided to expand his food truck or restaurant business internationally? Would you recommend product standardization or localization?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd