Search code examples
pythonmatrixscipylogarithm

How to calculate the base 2 log of a matrix?


The only function that I found that calculates the log of the matrix, and not of each component of the matrix, was scipy's logm() function, but it finds the log with base e, I need the base 2 log.


Solution

  • You can use the change-of-base formula to convert the base of the logarithm:

    log2(x) = logm(x) / logm(2)

    Mathematica StackExchange has some more in depth discussion of the math behind this:

    https://mathematica.stackexchange.com/a/92293