Directed probability graph - algorithm to reduce cycles?

后端 未结 4 1399
抹茶落季
抹茶落季 2021-02-07 21:28

Consider a directed graph which is traversed from first node 1 to some final nodes (which have no more outgoing edges). Each edge in the graph has a probability ass

4条回答
  •  独厮守ぢ
    2021-02-07 22:04

    I understand this as the following problem:

    Given an initial distribution to be on each node as a vector b and a Matrix A that stores the probability to jump from node i to node j in each time step, somewhat resembling an adjacency matrix.

    Then the distribution b_1 after one time step is A x b. The distribution b_2 after two time steps is A x b_1. Likewise, the distribution b_n is A^n x b.

    For an approximation of b_infinite, we can do the following:

    Vector final_probability(Matrix A, Vector b,
        Function Vector x Vector -> Scalar distance, Scalar threshold){
        b_old = b
        b_current = A x b
        while(distance(b_old,b_current) < threshold){
            b_old = b_current
            b_current = A x b_current
        }
        return b_current
    }
    

    (I used mathematical variable names for convencience)

    In other words, we assume that the sequence of distributions converges nicely after the given threshold. Might not hold true, but will usually work.

    You might want to add a maximal amount of iterations to that.

    Euclidean distance should work well as distance.

    (This uses the concept of a Markov Chain but is more of a pragmatical solution)

提交回复
热议问题