1

During the calculation of a Gaussian Mixture Model I have to calculate the pdf() of the multivariate Gaussian distribution. I do this using the scipy multivariate_normal() method. Now during the calculations I encounter the situation that I get an error which says

LinAlgError: singular matrix

Setting the allow_singular parameter of the scipy multivariate_normal() = True circumvents this error and I get a quite meaningful result: enter image description here

So how is scipy "allowing" for singularity and what are the consequences for the calculations? --> If there are no consequences, strictly speaking, this parameter could be set to TRUE by default (but it isn't).

Community
  • 1
  • 1
2Obe
  • 3,570
  • 6
  • 30
  • 54
  • *"During the calculation of a Gaussian Mixture Model ..."* Show the code. Without it, all anyone can do is speculate. It will be easier for someone to help you if you create a [minimal, complete and verifiable example](https://stackoverflow.com/help/mcve). – Warren Weckesser Jul 27 '18 at 12:53
  • @ Warren Weckesser thanks for your response. The actual question does not point to "how to code it" but "what is scipy doing in the background and what could be the concequences on my result" – 2Obe Jul 27 '18 at 12:56
  • 1
    That's true. I'm curious about what happens in your code that leads to a numerically singular matrix, but, as you said, that's just the preamble leading to the actual question about `allow_singular`. – Warren Weckesser Jul 27 '18 at 14:21

1 Answers1

2

This answer does not answer the question how scipy allows for singularity and also not what conseqences this behaviour has on the results but it gives a little bit more insight into what is going on during the calculations:

EDIT: I have posted an detailed answer on what is happening when we run into singularity issues during the calculations of a GMM here

2Obe
  • 3,570
  • 6
  • 30
  • 54
  • Maybe you wanto to put the answer in a jupyter notebook to see the LATEX notation or look at the following answer (https://stats.stackexchange.com/questions/359347/gaussian-mixture-model) – 2Obe Jul 27 '18 at 17:40