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

  Explain the difference between traditional and team working

Business Management Assignment- Compose a paper in which you explain the difference between traditional and team working environments.

  Nominal annual yield on investment

The bond is priced to yield 7.5% converted semi-annually. The coupons are reinvested in a fund paying 7.0% nominal, converted semi-annually. What is her nominal annual yield on this investment, convertible semi-annnually

  Discuss recent developments

Discuss recent developments (last 10 years) in China's wine market. Also include the potential for growth and the perspective (views) of the Chinese consumers in relation to countries of origin and relative quality of wine.

  How you perceive yourself professionally

A brief overview of how you perceive yourself professionally. You may include a photo. A description of attributes which contribute to professionalism in your chosen field such as professional attire, communication, and behavior.

  Consideration of strategic management phases

Why is the management's functional domain imperative in consideration of strategic management phases.

  Decision makers think and react to a problem

Explain how decision style can effect on the decision makers think and react to a problem.

  Show the stratification and diversity demogrphics

In what way does stratification occur within organizational culture? How are these occurrences created or supported within the organizations?

  Converting inputs to outputs activitiesrefer to an

converting inputs to outputs activitiesrefer to an interconnected set of activities that converts inputs to

  Marginal utility per doughnut

Suppose that Omar's marginal utility for cups of coffee is constant at 1.5 utils per cup, no matter how many cups he drinks. On the other hand, his marginal.

  Hiring process and managing a diverse workforce

Imagine that you are the HR Director at your current organization or an organization with which you are familiar. As the HR Director, you must use different employment law requirements to create methods and policies that support the promotion of a..

  Describe about workplace culture

Explain past and current experiences with organizational culture. Be as specific as possible and support your comments with examples.

  What is the gmc percent on a case

A wine retailer's standard markup on cost is 90%, but usually gives a 10% discount on case purchases. What is the GMC percent on a case (i.e., what is retail margin on price)?

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