[SciPy-User] Generating Sparse Random Matrix with positive nullspaces

federico vaggi vaggi.federico@gmail....
Thu Apr 4 04:15:20 CDT 2013

Hi everyone,

I'm trying to generate a set of random coefficients for a system of linear,
ordinary differential equations at steady state, such that:

AX = 0

Where A is the NxN matrix that contains the coefficients, and X is a Nx1 by
vector of variables.

Since the equations represent a set of chemical reactions, all values of X
at steady state have to be positive.  Furthermore, since the system is
relatively large
in size, A has to be sparse.

I tried two different approaches, neither really bearing any fruits.

Generation Nx1 vector of positive, normally distributed random numbers
(using scipy.truncnorm) and then finding the nullspace of the transpose of
that vector using an SVD:

AX = 0
X.T A.T = 0

Then solving for A.T, and transposing for A.

This usually gives me a matrix for A, but the matrix is not sparse.

The other approach is creating a sparse matrix A, then solving for the
nullvector X directly, but this usually gives me either negative values for
X, or, for very sparse A, mostly zero coefficients.

I think the easiest way to solve this is to create a random, sparse,
positive definite matrix A, then solving for X, but a cursory google
search(on my phone, so I might have missed something) hasn't revealed
anything.  Anyone have good suggestions?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20130404/34534645/attachment-0001.html 

More information about the SciPy-User mailing list