Skip to content
Advertisement

Tag: matrix

How to add noise to row/column selection in python

I want to select a specific row/column of a matrix i have, the twist however is that i want an added noise in the selection of the chosen row. Example I have a matrix m of size 100×100. I now want to select row 40 i.e. m[40,:]. What is actually wanted however is not an array with all values of

How to get this result when multiplying 1d-array by 2d-array?

I am struggling to figure out, how the output is calculated can you please explain? I have this multiplied by this array : c = np.array([3267. , 3375.9, 3484.8, 3630., 3740.]) the output is: array([1050885., 1068309., 1085733., 1103157., 1120581.]) Answer Grasping at straws because it feels like there’s not enough information to solve this. But, here is one way to

python iterate over arrays matrices

I am trying to create a new matrix(array) where I have been scouring the documentation in numpy but can’t find a function to satisfy this. Answer You’re looking for numpy.matmul. You’ll need to make the vectors have two dimensions (with a size of one in one of the dimensions). For example:

Compute row distance matrix using only for loops

I am stuck in trying to calculate a distance matrix from different binary arrays and I can only use for loops to resolve this… The problem consists of the following; Imagine I have a binary matrix built with different rows as follows, with dimension n=3,m=3 in this case: And I would like to achieve the following symmetric matrix, by adding

Reading Matrix from file

I have a txt file consisting some numbers with space and I want to make it as three 4*4 matrixes in python. Each matrix is also divided with two symbols in the text file. The format of the txt file is like this: My code is now like this but it is not showing the output I want. Can you

Multiply two matrices with different dimensions python

Error: ValueError: shapes (3,1) and (3,2) not aligned: 1 (dim 1) != 3 (dim 0) The error occurs because the matrices are different sizes, but how can I multiply two matrices with different size and where the resulting output should be: [-0.78 0.85]? Any help is appreciated! Mathematical question, for better understanding: A principal component analysis is carried out on

Distance Matrix Haversine

I am working on a data frame that looks like this : I’m trying to make a Haverisne distance matrix. Basically for each zone, I would like to calculate the distance between it and all the others in the dataframe. So there should be only 0s on the diagonal. Here is the Haversine function that I use but I can’t

Advertisement