Skip to content
Advertisement

Tag: matrix

Generate random binary matrix constrained to no null row

I want to generate a random binary matrix, so I’m using W=np.random.binomial(1, p, (n,n)). It works fine, but I want a constraint that no row is just of 0s. I create the following function: It also works fine, but it seems to me too inefficient. Is there a faster way to create this constraint? Answer When the matrix is large,

How to make recursive function hold it’s original parameter value?

I’m trying to write a function that calculates the determinant of a square matrix using recursion. The parameter of the oldest function – the first one called – changes to the matrix returned by scale_down() and I don’t know why. I tried substituting “matrix” with “var” in order not to use it directly, but it amounted to nothing. The code

Generating 2D matrix in python with all the elements is 0

I’m making a game in python. The map of the game is a stored as matrix with number of line and column are equal, the matrix look kind of like this: I want to make a matrix generator to store it in ram when the game is openned in stead of store the whole matrix like that in the game

Python, plot matrix diagonal elements

I have an 120×70 matrix of which I want to graph diagonal lines. for ease of typing here, I will explain my problem with a smaller 4×4 matrix. index 2020 2021 2022 2023 0 1 2 5 7 1 3 5 8 10 0 1 2 5 3 1 3 5 8 4 I now want to graph for example

string to complex matrix representation in python

I have the following example string: s =”1 1+in1-i 0″ Now I have to turn this string into a complex matrix. I am aware of the np.matrix() function but it is not designed for a complex matrix. Maybe some of you can provide me some ideas of how I can go forward. I also tried to split at n but

Advertisement