Chapter 4. Convenience Functions for Your Convenience

As we have seen, NumPy has a great number of functions. Many of those functions exist just for convenience, and knowing them will greatly increase your productivity. This includes functions that select certain parts of your arrays (based on a Boolean condition, for instance) or manipulate polynomials. This chapter has an example of computing correlation to give you a taste of data analysis with NumPy.

In this chapter, we shall cover the following topics:

  • Data selection and extraction
  • Simple data analysis
  • Examples of correlation of returns
  • Polynomials
  • Linear algebra functions

In Chapter 3, Getting Familiar with Commonly Used Functions, we had one data file to play around with. Things have improved in this chapter—we now have two data files. Let's explore the data with NumPy.

Correlation

Have you noticed that the stock price of some companies will be closely followed by another, usually a rival in the same sector? The theoretical explanation is that because these two companies are in the same type of business, they share the same challenges, require the same materials and resources, and compete for the same type of customers.

You could think of many possible pairs, but you need to check for a real relationship. One way is to take a look at the correlation of the stock returns of both stocks (see https://www.khanacademy.org/math/probability/statistical-studies/types-of-studies/v/correlation-and-causality). A high correlation implies a relationship of some sort. It is not proof of causality though, especially if you don't use sufficient data.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset