PIXELBANKv9.1.0
Menu

Softmax Transition Probabilities

Convert frame similarities to transition probabilities using softmax.

For varied video texture playback, we use probabilistic transitions instead of always jumping to the best match. The transition probability from frame ii to frame jj is:

P(j∣i)=exp⁑(βˆ’Dij/Οƒ)βˆ‘kexp⁑(βˆ’Dik/Οƒ)P(j|i) = \frac{\exp(-D_{ij}/\sigma)}{\sum_k \exp(-D_{ik}/\sigma)}

where:

  • DijD_{ij} is the dissimilarity from ii to jj
  • Οƒ\sigma is a temperature parameter
  • Lower dissimilarity = higher probability

This creates smooth random playback that prefers good transitions but allows variety.

Example:

Input:
transition_probs([0, 10, 10], 10)
Output:
[0.5761, 0.2119, 0.2119]
Reasoning:

Converting similarities [0, 10, 10] with Οƒ=10: exp(-0/10) = 1.0 exp(-10/10) = 0.3679 exp(-10/10) = 0.3679

  • sum = 1.7358
  • Probs = [1.0/1.7358, 0.3679/1.7358, 0.3679/1.7358] β‰ˆ [0.576, 0.212, 0.212]

Constraints:

  • similarities: list of similarity scores from current frame to all frames
  • sigma: temperature parameter (higher = more uniform)
  • Return probability distribution (sums to 1)
πŸ”’

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.
Softmax Transition Probabilities - Medium | PixelBank