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

  What are the primary predictions of the model

Define leadership ans situation factors included in Fiedlers Contingency Model. What are the primary predictions of the model?

  Create a basic outline that captures the key points

Create a basic outline that captures the key points. As a guide for your outline, it will be helpful to note the "key points" that are listed at the end.

  Internal consultant

What if the Internal Consultant has intimate knowledge of the organization and has a different perspective on Operations than one particular line manager. Is it permissable to say 'no' in this case? why or why not?

  Two are the most important to a restaurant success

The location of a restaurant is very important to its financial success. Analyze key location criteria to determine which two are the most important to a restaurant's success

  How the information gap between generations and cultures

Discuss how the information gap between generations, cultures, income levels, and education can be resolved.

  Company organization was not able to achieve their goals

Business Management, Need example about a company organization was not able to achieve their goals. Why did this occur?

  Develop a faux special event

As outlined in the textbook, there are five stages to the event planning process. Utilizing this five stage process, develop a faux special event to be held in a location of your choice.

  Purchasing function to a third-party in louisiana

As a continuation of the story described in Case One, Jackson Excursions (JE) decides that it is the best interest of their company to outsource their purchasing function to a third-party in Louisiana, Jones Procurement. Sonny Jackson has been han..

  Primary sourcesexplain what is the purpose of using primary

primary sourcesexplain what is the purpose of using primary sources in academic writing? what strategies might you use

  Develop your revised companys mission statement

Create your revised NAB company name and explain its significance. Develop your revised company's Mission Statement and provide a rationale for its components.

  Write an essay about pest analysis of hong kong

Write an essay about PEST analysis of Hong Kong. A PEST analysis is a business measurement tool. PEST is an acronym for Political, Economic, Social and Technological factors, which are used to assess market for a business.

  How hard or easy will it probably be to make profits

Think about all the different ways that you could be in businesses and involved somehow with Chinese fireworks. List 4 of different types of businesses.

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