Goal: Given a series of binary digits, see where there's a longer bunch of 1's (even if there are a few 0's mixed in).
Background: I'm programming a monte carlo simulation in SAS, and have (say) 100k variables with a 0 or 1. I want to see if (somewhere) there is a cluster that is pretty dense. I don't think 5 in a row of one's would be sufficiently dense (00011111010...), but maybe 100 one's in (01111...11111) would be great. So, I guess I want a localized cluster.
I'm having the code for the variable be, so that n1, n2, etc. would be either 0 or 1,:
array var_of_binary{*} n1 - n100000;
Am I asking for a solution (impossible) of the SAT-CNF which is "a classic problem that is known to be NP-complete"? (PS: I don't understand what that is, but I know it's unsolvable and too complex.)
I think making multiple passes computing density of length 21, 22, 23, ..., 1000 would work (this is pseudo-code, which I did not try to run):
static_max_of_1k = 1000; /*check in lengths up to 1k, perhaps less*/
do i= 100 to static_max_of_1k ;
do j=1 to 999000;
density1 = sum(of var_of_binary{j} - var_of_binary{j+i })/i;
/* save value of density1, probably in an array */
end;
end;
Note 1: I don't want a C++ solution (unless it works immediately in SAS as a subroutine without alteration).
Note 2: I don't want recursive code, since if it blows up, I wouldn't have a clue to debug it. (I know my limitations.)
Note 3: I guess I'm doing a 1-dimensional variation of Detect High density pixel areas in a binary image which is sort of cool and a nice photo, but (again) beyond me. I appreciated from afar the metacode of SimpleBlobDetector Class Reference. I think I'm in over my head.