Found 33676 Articles for Programming

Compute the Reciprocal for all elements in a NumPy array

Niharika Aitam
Updated on 09-Aug-2023 09:50:48

547 Views

The reciprocal of a number is defined as the multiplicative inverse of that number, when we have a non-zero number ‘a’ then the reciprocal of ‘a’ will be ‘b’, Hence, a * b = 1. In other words, reciprocal of ‘a’ is given as ‘1/a’. The reciprocal() function We can calculate the reciprocal of an array using the reciprocal() function of the Numpy library. This function accepts an array as a parameter and returns the reciprocal of the elements of the given array. The within the same shape and size of the original array. Syntax Following is the syntax for ... Read More

Compute the outer product of two given vectors using NumPy in Python

Niharika Aitam
Updated on 07-Aug-2023 19:35:47

323 Views

The Outer product of two vectors is the matrix obtained by multiplying each element of the vector A with each element in the vector B. The outer product of the vectors a and b is given as a ⊗ b. The following is the mathematical formula for calculating the outer product.a ⊗ b = [a[0] * b, a[1] * b, ..., a[m-1] * b] Where, a, b are the vectors. denotes the element-wise multiplication of two vectors. The output of the outer product is a matrix in which i and j are the elements of the ... Read More

How to Change the Background of an Image with Green Screen Background in MATLAB?

Manish Kumar Saini
Updated on 07-Aug-2023 17:30:09

387 Views

In this article, we learn how to change the green background of an image to some other background using MATLAB programming. The concept of changing a green screen background to another background involves the use of a technology called “chroma key”. This technology detects the absolute green color in the image and omits it from the image. Then, we can apply another image or color as the background to the image. Algorithm The step−by−step process of changing the green screen background of an image with another background in MATLAB is explained below: Step (1) − Read the input image with ... Read More

How to Calculate Variance in MATLAB?

Manish Kumar Saini
Updated on 07-Aug-2023 17:27:31

503 Views

In this article, we will explore how to calculate variance in MATLAB. In mathematics, variance is a statistical tool used to measure the degree of dispersion of a set of data points around its average value. It is widely used to quantify the diversity or variability of a set of data points. We can compute variance of a data set by using the following formula: $\mathrm{Var=\frac{\displaystyle\sum\limits_{i=1}^n (x_i −\bar{x})^2}{n}}$ Where, xi is the individual data points, is the average of data set, and n is the total number of data points in the set. The following sections of this articles ... Read More

Compute the median of the flattened NumPy array

Niharika Aitam
Updated on 07-Aug-2023 18:17:02

142 Views

MedianThe median is the statistical measure for the central tendency that represents the middle value of the sorted list of values. In other words, we can say that the median is the value which separates the upper half of the dataset from the lower half of the dataset. The mathematical formula for calculating the median is as follows when the total number of elements is odd. Median = (n+1)/2 Where, n is the last element from the given set. Flattened array Flattening is a process of reducing the dimensionality of an array. flattened array is a 1-d ... Read More

Compute the mean, standard deviation, and variance of a given NumPy array

Niharika Aitam
Updated on 07-Aug-2023 18:08:11

563 Views

Mean, Standard Deviation and Variance are the statistical measures which are used to describe the distribution of the given dataset data. In Numpy library, we have the functions to calculate the mean, standard deviation and variance of the arrays. Let’s see one by one in detail. Mean Mean is also known as average, which is the sum of all the elements in the array divided by the total number of elements. It is used to represent the central tendency of the data. Syntax Following is the syntax for applying the mean function on the arrays - numpy.mean(arr) ... Read More

How to Calculate the Impulse Response in MATLAB?

Manish Kumar Saini
Updated on 07-Aug-2023 17:24:44

804 Views

In this article, we will learn ow to calculate the impulse response of a system in MATLAB. Impulse response is an elementary concept used in analyzing and understanding the behavior of systems for an impulse input. It is mainly used to analyze the linear time invariant systems like digital filters, electronic circuits, signal processing systems, control systems, and more. Impulse response of a system can be defined as follows: The response of a system when an impulse input signal is applied to it, is called the impulse response. It is denoted as h(t) for continuous time systems and h[n] for ... Read More

How To Calculate Standard Deviation in MATLAB?

Manish Kumar Saini
Updated on 07-Aug-2023 17:21:07

602 Views

In this article, we will learn to calculate standard deviation in MATLAB. Standard deviation is a mathematical operation that gives the measure of variation in a set of data points. The standard deviation is used to study the dispersion of data around their average value. If a set of data points has a low standard deviation, it indicates that the data points tend to nearer to the average value. Whereas, the high standard deviation specifies a large dispersion of data points out from their average value. In MATLAB, we can calculate the standard deviation by using a built−in function named, ... Read More

How to Calculate Moving Sum in MATLAB?

Manish Kumar Saini
Updated on 07-Aug-2023 17:17:53

277 Views

In this article, we will explore how to calculate moving sum using MATLAB programming. But before that let us have a look into the concept of moving sum. What is Moving Sum? Moving sum is a mathematical operation that allows to calculate the sum of a set of numbers over a specified interval, known as window size or rolling window. It is also known as cumulative sum or rolling sum. Moving sum is widely used in the field of data analysis and signal processing. Moving sum is generally performed on sequential data where the order of data elements is significant ... Read More

Compute the inverse of a matrix using inv() function of NumPy

Niharika Aitam
Updated on 07-Aug-2023 18:02:58

180 Views

The inverse matrix is a matrix that gives a multiplicative identity when multiplied with its original matrix. It is denoted by A-1. The inverse matrix can be calculated for the square matrices with the n x n size. The mathematical formula given for calculating the inverse matrix is as follows. A-1 . A = A . A-1 = I Where, A is the original matrix. A-1 is the inverse of the original matrix A. I is the identity matrix. Let’s take the original matrix as A with the size 2 x 2 and elements as ... Read More

Advertisements