Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to measure complexity of a string?

I have a few long strings (~ 1.000.000 chars). Each string only contains symbols from the defined alphabet, for example

A = {1,2,3}

Sample strings

string S1 = "1111111111 ..."; //[meta complexity] = 0
string S2 = "1111222333 ..."; //[meta complexity] = 10
string S3 = "1213323133 ..."; //[meta complexity] = 100

Q What kind of measures can I use to quantify the complexity of these strings? I can see that S1 is less complex than S3, but how can I do that programmatically from .NET? Any algorithm or point to the tool/literature would be greatly appreciated.

Edit

I tried Shannon entropy, but it turned out that it is not really useful for me. I will have the same H value for these sequences AAABBBCCC and ABCABCABC and ACCCBABAB and BBACCABAC


This is what I ended up doing
like image 386
oleksii Avatar asked May 21 '11 20:05

oleksii


1 Answers

Compressing the strings using standard techniques such as zip gives a good indication of the compexity.

Good compression rate ≈ lower complexity
Bad compression rate ≈ higher complexity

like image 110
aioobe Avatar answered Oct 18 '22 21:10

aioobe