Describe similarities and differences between numpy

Assignment Help Business Management
Reference no: EM132203061

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: EM132203061

Questions Cloud

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?
Difference between a microcontroller or microprocessor : What is the primary difference between a microcontroller or microprocessor, and an FPGA?

Reviews

Write a Review

Business Management Questions & Answers

  Important in the business environment

1. Explain why ethics is important in the business environment.

  Undertake a more expansionary fiscal policy

In trade negotiations with the Japanese over the large US trade deficit with Japan, the US administration has urged the Japanese government to undertake a more expansionary fiscal policy. Explain how this might affect the US trade deficit with Jap..

  Achieve better performance

Describe a time at school when you were dissatisfied with your poor mark, using goal setting theory, suggest three strategies

  Describe the organization current job design

For this paper, first select an organization with which you are familiar. Describe the organization's current job design approach and assess its effectiveness.

  Characterize the dominant strategy used

Characterize the dominant strategy used for each of Janet's production plans, and provide a brief summary of the strengths and weaknesses of each.

  Automated highways and self-driving vehicles

Study progress, safety, and social issues related to an automated system such as automated highways and self-driving vehicles.

  Visit the godiva web site and describe some of the features

read want to buy chocolate online? try godiva.com on page 10 of the textbook and answer the following questions1.

  Which statements is not true regarding buyers right to cover

Which of the following statements is not true regarding the buyer's right to cover? Under UCC warranty law, which of the following is a FALSE statement?

  Limiting patients to coverage of in-network services

Identify the basic factors of financial management with regard to the process of MCO coverage, such as limiting patients to coverage of in-network services.

  Availability of erp system as the primary data source

Be sure to address the benefits, risks, and other issues associated with using external data. Discuss the availability of ERP system as the primary data source.

  Functional strategy and value chain management

Please explain the role of functional strategy and value chain management.

  Describe the main types of business entities

Apply product liability law and determine what issues are present. How would you advise your client to mitigate those issues?

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