I'm trying to do a matrix operation. the original logic we have in java is like this:
inverseMatrix = LUDecomposition(matrix).getSolver().getInverse()
The LUDecomposition used here is: https://commons.apache.org/proper/commons-math/javadocs/api-3.6/org/apache/commons/math3/linear/LUDecomposition.html#getSolver()
I'm finding a way to implement this in python, does anyone know what would be a good way to do so?
Sorry I'm not quite familiar with matrix operations...Thanks a lot!
Related
So i'm using Python, i'm not new to Python, but obviously not advanced. Anyway, i have an algorithm that i want to implement using Python, but I want to make it as quick as possible.
My question is: can we find a benchmark comparing most operations but with different "codes"? For example, if i have a list and i want to divide all elements by 2, there are multiple ways to code it
newlist=[e/2 for e in oldlist]
or using a loop
newlist=[] for e in oldlist: newlist.append(e/2)
or even using a library (scipy, numpy etc...). Which way to code this is the fastest? This is a simple example but there are so many operations i don't know which way to code it is the best, and i may not now every way to code it either...
So i ask the question for Python, but it is also a viable question for other programming languages
I am curently working with non-parametrical statistics in python using PyMc3. And would like to implement a normal-inverse-wishart function as a prior to my model. But after short research I had to find out that there is no predefined function for that. So before trying to rebuild it all from zero, I wanted to ask you if someone has experience in doing that and if there is an easy way to do it.
Thanks in advance and best regards!
Leon
I'm trying to understand LSH implementation. I found this on stackoverflow
Can you suggest a good minhash implementation?
and I try to follow the Duhaime's implementation.
In my case, i wish apply a permutation on the minhash(like in datasketch tool), and i think this implementation isn't good for me.
I already start from sparse matrix.
Someone can give some suggestion about this tecnique? isn't very diffuse so i don't find more material about implementation with Python.
I hope in you help.
Don't just look for example code. Try to understand the math behind it.
Obviously, maxhash should work similar. Or you could omit 0 values. But then you should double check the math.
So I have a code that generates various matrices. These matrices need to be stored in a block diagonal matrix. This should be fairly simply as I can use scipy's:
scipy.linalg.block_diag(*arrs)
However the problem I have is I don't know how many matrices will need to be stored like this. I want to keep things as simply as possible (naturally). I thought of doing something like:
scipy.linalg.block_diag( matrix_list[ii] for ii in range(len(matrix_list)) )
But this doesn't work. I can think of a few other ways to do it... but they all become quite convoluted for something I feel should be much simpler.
Does anyone have an idea (or know) a simple way of carrying this out?
Thanks in advance!
When you do:
scipy.linalg.block_diag( matrix_list[ii] for ii in range(len(matrix_list)) )
you're passing a generator expression to block_diag, which is not the way to use it.
Instead, use the * opertor, for expanding the argument list in the function call, like:
scipy.linalg.block_diag(*matrix_list)
Does somebody know about a entropy minimization implementation in python?
I want to use this to correct inhomogeneity in histology images.
Reference about the algorithm I am talking about.
I suspect that you'll have to hack something together yourself, maybe using PIL and pyentropy.