Sample Entropy Calculation
Model was written in NetLogo 6.4.0
•
Viewed 96 times
•
Downloaded 0 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
globals [ m ;; length of substrings that can be derived from the input-string substrings ;; list of the substrings derived from the input-string substr-copy ;; a copy of the previous list similar ;; couple of similar substrings in the previous list sampen ;; the sample entropy of the input-string index ] ;; ----------- CALCULATING SAMPLE ENTROPY FOR THE INPUT-STRING ------------------ ;; ------------------------------------------------------------------------------- to compute-sample-entropy ca output-print "" output-print "Let's compute the sample entropy for the given sequence (with r=0 and m=2)." output-print "" set input-string word input-string "_" ;; Creating patterns with m = 2 set m 2 set index 0 set similar 0 set substrings [] built-substrings let substrings2 substrings output-print word "Set of patterns with m = 2 --> " substrings2 ;; evaluate each pair of patterns ;; to determine if they are similar within a tolerance of 𝑟 = 0. set substr-copy substrings2 calculate-distancies let S2 similar output-print word "Similar patterns of length = 2 --> " S2 output-print "" if S2 = 0 [output-print "I can't compute the sample entropy for this string" output-print "because the similar patterns of length 2 is null" stop] ;; Creating patterns with m = 3 set m m + 1 set index 0 set similar 0 set substrings [] built-substrings set input-string but-last input-string let substrings3 substrings output-print word "Set of patterns with m + 1 = 3 --> " substrings3 set substr-copy substrings3 calculate-distancies let S3 similar output-print word "Similar patterns of length = 3 --> " S3 output-print "" if S3 = 0 [output-print "I can't compute the sample entropy for this string" output-print "because the similar patterns of length 3 is null" stop] ;; sample entropy computation set sampen precision (- ln (S3 / S2)) 5 output-type word "*** Sample Entropy = - ln " S3 output-type word " / " S2 output-type word " = " sampen output-print " ***" end to built-substrings set substrings lput (substring input-string index (index + m)) substrings set index index + 1 if index < (length input-string - m) [built-substrings] end to calculate-distancies set index 0 let short.copy but-first substr-copy repeat length short.copy [ if item 0 substr-copy = item index short.copy [set similar similar + 1] set index index + 1 ] if length short.copy > 1 [ set substr-copy but-first substr-copy calculate-distancies ] set index 0 end
There is only one version of this model, created about 1 month ago by Cosimo Leuci.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Sample Entropy Calculation.png | preview | Preview for 'Sample Entropy Calculation' | about 1 month ago, by Cosimo Leuci | Download |
This model does not have any ancestors.
This model does not have any descendants.