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

  Instrumental in bringing about the leadership

During a change initiative you've experienced, what type of short term wins have been instrumental in bringing about the leadership's desired results?

  Basic security considerations

In this section, you will briefly explain what the owner of your business must consider in regard to security and privacy.

  Bargaining in project management

Describe an example where a project manager must use the power of bargaining when working to complete a project on time and on budget.

  Making contribution format segmented income statements

Prepare contribution format segmented income statements, the first showing the total company broken down between sales territories and then showing the Central Territory broken down by product line.

  Perceptions and stereotypinga good example of stereotyping

perceptions and stereotypinga good example of stereotyping that you have witnessed or have personally experienced.

  Why marketing is important for your career

The latest trends in Marketing (short background, current situation, best practices and the future). Why Marketing is important for your career

  Explain the resources and capabilities that are required

Specify the unique value the company will offer in the selected markets. Discuss the resources and capabilities that are required. Analyze how the company will capture value and sustain competitive advantage over time.

  Write a paper about competition and teamwork in workplace

Write a business communication research paper about competition and teamwork in workplace.

  What is the forward premium or discount

What is the swap rate on euros?- What is the forward premium or discount on 180-day euros?- What is the forward discount or premium associated with buying 90-day Swiss francs?

  Explain a specific example

"Explain a specific example in which you used critical thinking/problem solving strategies to solve a problem in the real world."

  Knowledge of the conventional leader-celebratory

1. Draw on your knowledge of the conventional leader-celebratory approaches to leadership. Describe Adair's three circles model. In your answer explain the model's core management responsibilities.

  Research methods to generate revenue and participation

Research methods of using digital media and technology to generate revenue and participation in the event you are planning and as a method of involving the community and securing and motivating volunteers.

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