Using conditional statements to select parts of NumPy arrays in Python

We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. In addition to simply using indexing to select elements from a Numpy array, Python lets you easily use conditional tests to systematically select parts of a Numpy array. In the following example, elements less than 0.8 from a two-dimensional array is selected via a conditional test inside the brackets, and the returning result is Read more…

Using apply_along_axis() to apply an aggregate function upon an Numpy array in Python

We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. As an alternative to for looping, Numpy provides an aggregate function, apply_along_axis(), that applies various summary functions upon an array’s column or rows. The function has an option paraemter ‘axis’, which stands for columns when it equals to 0 and for rows when it is 1. In addition to functions that come from Python Read more…

How to iterate over an Numpy array in Python

We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. If we want to get the contents of an Numpy array element by element, a for loop can be performed. The usage of a for loop upon an Numpy array is quite similar as for a Python list, which is show in the following code example. For two-dimensional array, for loop will first looping Read more…

Indexing and slicing Numpy arrays in Python

We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. When an Numpy array is created, its elements can be returned by indexing. Indexing of array elements is implemented by using brackets. If there are several non contiguous elements to be indexed, a list of indices should be appended. Similar as for Python list, negative indexing represents indexing number from the end of an Read more…

Matrix operations of Numpy arrays in Python

We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. Matrix addition and subtraction of Numpy arrays of same size are element-wise, i.e. elements in the resulting matrix are the results of the corresponding elements of the inputting matrix at the same position, so the resulting matrix has the same shape as the inputting matrices. On the contrary, matrix multiplication of two Numpy arrays Read more…

Arithmetic operations of Numpy arrays in Python

We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. Arithmetic operations of Numpy ndarrays are element-wise. If an array has addition, subtraction, multiplication or division with a scalar, each element will have the same operation and the result is also an array. Two Numpy arrays of same dimensions can perform similar arithmetic operations as with a scalar. The resulting array has the same Read more…

Creating Numpy arrays using ones(),zeros(),arange(), reshape(), linspace() and random() in Python

We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. In addition to using array() function that passes a list or tuple to generate an Numpy array in Python, there are lots of ready-made functions that make it possible to generate large size Numpy arrays in Python. Following code examples show some of the most common functions in that respect. You can also watch Read more…

Introducing Numpy array in Python

We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. Numpy is a large module in Python programming. It handles mainly numeric data analysis, and is also the basis of another large module, Pandas in Python. The heart of Numpy is data object type ndarray. Numpy array stores same type of data in an array. An array usually has dimension (how many axes, or Read more…

How to calculate probability from Negative Binomial distribution in R

We provide effective and economically affordable online training courses for R and Python, click here for more details and course registration ! Negative binomial distribution is used to model the particular probability of k-th success occurring at x-th Bernoulli trial, which is equivalent to say that it has experienced x-1 trial and the last trial is a success. A Bernoulli trial is a trial with binary result, success and failure, with a constant success rate Read more…

How to calculate probability of Hypergeometric distribution in R

We provide effective and economically affordable online training courses for R and Python, click here for more details and course registration ! Hypergeometric distribution is connected with taking n items (no replacement) from N items, where k items labeled success and N-k items failure. The success number x of n selected items follows hypergeometric distribution. To calculate the probability of x using R, function dhyper() can be applied. The basic form of the function is: Read more…