Results 1 to 1 of 1

Thread: Discrete Probability Detector in [VB6, VBA, JS]

  1. #1

    Thread Starter
    Lively Member Paul A. Gagniuc's Avatar
    Join Date
    Feb 2022
    Location
    Romania, Bucharest
    Posts
    65

    Discrete Probability Detector in [VB6, VBA, JS]

    These applications use an algorithm called DPD (Discrete Probability Detector) that transforms any sequence of symbols into a transition matrix. The algorithm may receive special characters from the entire ASCII range. These characters can be letters, numbers or special characters (ie. `7Eu9f$*"). The number of symbol/character types that make up a string, represent the number of states in a Markov chain. Thus, DPD is able to detect the number of states from the sequence and calculate the transition probabilities between these states. The final result of the algorithm is represented by a transition matrix (square matrix) which contains the transition probabilities between these symbol types (or states). The transition matrix can be further used for different prediction methods, such as Markov chains or Hidden Markov Models. This version of DPD is made in HTML/JavaScript/CSS, VB6, VBA (Excel).


    Download: Discrete Probability Detector in [VB6, VBA, JS]


    Name:  DPD.jpg
Views: 277
Size:  40.3 KB


    Code:
    Function Discrete_Probability_Detector(ByVal S As String)
     
     
        Dim e() As String
    
        Dim m() As String
    
        Dim l(0 To 1) As String
     
      
        k = Len(S)
    
        w = 1
      
     
        For i = 1 To k
    
            q = 1
    
            For j = 0 To Len(a)
    
                x = Mid(S, i, 1)
    
                y = Mid(a, j + 1, 1)
    
                If x = y Then q = 0
    
            Next j
    
            If q = 1 Then a = a & x
    
        Next i
    
    
        d = Len(a)
    
        ReDim e(w To d, 0 To 1) As String
    
        ReDim m(w To d, w To d) As String
    
       
        For i = w To d
    
            For j = w To d
    
              m(i, j) = 0
    
              If j = w Then
    
                e(i, 0) = Mid(a, i, 1)
    
                e(i, 1) = 0
    
              End If
    
            Next j
    
        Next i
     
     
        For i = 1 To k - 1
    
            l(0) = Mid(S, i, 1)
    
            l(1) = Mid(S, i + 1, 1)
    
            For j = w To d
    
                If l(0) = e(j, 0) Then
    
                   e(j, 1) = Val(e(j, 1)) + 1
    
                   r = j
    
                End If
    
                If l(1) = e(j, 0) Then c = j
    
            Next j
    
            m(r, c) = Val(m(r, c)) + 1
    
        Next i
     
     
        For i = w To d
    
            For j = w To d
    
                If Val(e(i, 1)) > 0 Then
    
                     m(i, j) = Val(m(i, j)) / Val(e(i, 1))
    
                End If
    
            Next j
    
        Next i
     
     
    End Function
    Last edited by Paul A. Gagniuc; Feb 27th, 2022 at 11:06 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width