Do you want BuboFlash to help you learning these things? Click here to log in or create user.

[unknown IMAGE 5038190234892]

Tags

#data-type-definition #has-images #numpy-ndarray-datatypes-and-operations #python-for-data-science

Question

Describe a case where it is important to define the data type when creating an array.

Answer

As we showed you previously, datatypes matter. If you try to assign an element in an integer array, to a floating point value, you’ll get an error. Let’s start by just doing some basics with with these. We’ll start by creating an array and giving it two integers. The type of the array is, unsurprisingly, gonna be an integer. Similarly, if we give it floats, we’re gonna get back a float array. We can also explicitly say the type we want, by creating the array. Here, we’re saying that we want the type to be integer. Where this gets useful is when you wanna force a different type in the input. Here, I’m providing two floats to the constructor, and I’m telling it to make the type integer. Numpy will do this, it just forces the floats to drop their decimal, effectively doing the floor function. Similarly, we can force ints to be floats. This is less problematic because we’re not losing any information. The reason you might wanna do this is if you presently have integer data, but expect for the values to change to floats in the future. You don’t want Python to pick int datatypes here, only to run into problems later. Just keep in mind that datatypes matter for ndarrays.

status | not learned | measured difficulty | 37% [default] | last interval [days] | |||
---|---|---|---|---|---|---|---|

repetition number in this series | 0 | memorised on | scheduled repetition | ||||

scheduled repetition interval | last repetition or drill |

As we showed you previously, datatypes matter. If you try to assign an element in an integer array, to a floating point value, you’ll get an error. Let’s start by just doing some basics with with these. We’ll start by creating an array and giving it two integers. The type of the array is, unsurprisingly, gonna be an integer. Similarly, if we give it floats, we’re gonna get back a float array. We can also explicitly say the type we want, by creating the array. Here, we’re saying that we want the type to be integer. Where this gets useful is when you wanna force a different type in the input. Here, I’m providing two floats to the constructor, and I’m telling it to make the type integer. Numpy will do this, it just forces the floats to drop their decimal, effectively doing the floor function. Similarly, we can force ints to be floats. This is less problematic because we’re not losing any information. The reason you might wanna do this is if you presently have integer data, but expect for the values to change to floats in the future. You don’t want Python to pick int datatypes here, only to run into problems later. Just keep in mind that datatypes matter for ndarrays.

Tags

#arithmetic-mean #average #probability-random-variables-statistics-and-random-processes #sample-mean

Question

Discuss about the sample mean. Is it a random variable? Why?

Answer

An important measure of central tendency for a set of data is the **sample mean**, also known as the **arithmetic mean**, or commonly called the **average**. The sample mean summarizes the set of data values into one approximate value. The sample mean, however, may not be a data value in the set. The sample mean takes all of the data values into account, as all of the data values are added and then divided by the number of data values in the set. Assuming the data set consists of \(n \geq 1\) datavalues, \(X_1 , X_2 , \ldots , X_n\) , the sample mean is deﬁned as follows:

\(\overline{X}_n = \left( \displaystyle \frac{1}{n} \right) \displaystyle \sum_{i=1}^n X_i \tag{8.1}\)

Note that the sum of the deviations of the individual observations of a sample about the sample mean is always zero. It is important to note that \(\overline{X}_n\) is a function of the data set, therefore when the data set changes, the value of the sample mean likely changes. The sample mean is thus a random variable, has a probability density function, and as such, has an expected value and a variance.

status | not learned | measured difficulty | 37% [default] | last interval [days] | |||
---|---|---|---|---|---|---|---|

repetition number in this series | 0 | memorised on | scheduled repetition | ||||

scheduled repetition interval | last repetition or drill |

An important measure of central tendency for a set of data is the sample mean, also known as the arithmetic mean, or commonly called the average. The sample mean summarizes the set of data values into one approximate value. The sample mean, however, may not be a data value in the set. The sample mean takes all of the data values into account, as all of the data values are added and then divided by the number of data values in the set. Assuming the data set consists of \(n \geq 1\) datavalues, \(X_1 , X_2 , \ldots , X_n\) , the sample mean is deﬁned as follows: \(\overline{X}_n = \left( \displaystyle \frac{1}{n} \right) \displaystyle \sum_{i=1}^n X_i \tag{8.1}\) Note that the sum of the deviations of the individual observations of a sample about the sample mean is always zero. It is important to note that \(\overline{X}_n\) is a function of the data set, therefore when the data set changes, the value of the sample mean likely changes. The sample mean is thus a random variable, has a probability density function, and as such, has an expected value and a variance.

status | not read | reprioritisations | ||
---|---|---|---|---|

last reprioritisation on | reading queue position [%] | |||

started reading on | finished reading on |

[unknown IMAGE 5524445596940]

Tags

#has-images

Question

Differentiage average from expected value.

status | not learned | measured difficulty | 37% [default] | last interval [days] | |||
---|---|---|---|---|---|---|---|

repetition number in this series | 0 | memorised on | scheduled repetition | ||||

scheduled repetition interval | last repetition or drill |