0

Given an n by m matrix A, filled with only 0s and 1s, and an n by 1 matrix b, filled with non-negative integer values, I want to find the probability that a specific element of x is 1, if I were to choose a random m by 1 matrix x containing only 0s and 1s that solves the equation Ax = b.

Let me give an example.

A = [[1, 1],
     [1, 1]]

x = [x_1, x_2]

b = [[1],
     [1]]

The only solutions to Ax = b are x = |1 0| and x = |0 1|. Therefore, the probability of x_1 being 1 is 50% (or 0.5) and the probability of x_2 being 1 is also 50% (or 0.5). This is what I am trying to achieve, only for arbitrarily large matrices.

I know this can be done by brute force, by the time complexity is atrocious. Is there anyway to implement this (preferably in python), faster than brute-force?

Thanks!

Ghull
  • 1
  • 1
  • 1
    I’m voting to close this question because it is about mathematics, not programming, and therefore would be a better fit at [math.se] – Pranav Hosangadi Feb 16 '23 at 21:48
  • @PranavHosangadi I'm not trying to find a formula for the problem, I'm trying to code it? – Ghull Feb 16 '23 at 22:15
  • 1
    This is *not* a math problem. This is a typical numerical problem or a combinatoric one. Researcher works on this kind of problem in *computer science* lab since decades. This problem can be reformulated to be a SAT formula. Unfortunately, solving SAT formula is NP-complete. This means the best known algorithm is exponential. There might be a fast specialized algorithm for solving some specific matrices but certainly not a general one (unless the P=NP hypothesis is true, which is assumed to be rather wrong). – Jérôme Richard Feb 17 '23 at 00:34
  • 1
    Not finding all solutions but only the probability might be faster to compute, but I still think it is NP-complete too since finding if the probability >=0 should be equivalent to finding 1 solution of the SAT formula which is NP-complete. I guess the best option for you is to use approximation algorithms. For very small matrices, SAT solvers might give results in a reasonable time. – Jérôme Richard Feb 17 '23 at 00:39
  • @JérômeRichard SAT solvers are a great idea! I've actually been assisting with research in Complexity Theory at my university, and I'm slightly embarassed I didn't see the relation. Thanks for the idea! – Ghull Feb 17 '23 at 12:31
  • Considering the requirement to find a probability, rather than just determining whether it's possible for a cell to have value 1, I suspect this is going to be [♯P-hard](https://en.wikipedia.org/wiki/%E2%99%AFP), which is even *worse* than NP-hard. – user2357112 Feb 24 '23 at 20:33

0 Answers0