Mining Statistically Significant Substrings Based on the Chi-Square Measure

Given the vast reservoirs of data stored worldwide, efficient mining of data from a large information store has emerged as a great challenge. Many databases like that of intrusion detection systems, web-click records, player statistics, texts, proteins etc., store strings or sequences. Searching for an unusual pattern within such long strings of data has emerged as a requirement for diverse applications. Given a string, the problem then is to identify the substrings that differs the most from the expected or normal behavior, i.e., the substrings that are statistically significant. In other words, these substrings are less likely to occur due to chance alone and may point to some interesting information or phenomenon that warrants further exploration. To this end, we use the chi-square measure. We propose two heuristics for retrieving the top-k substrings with the largest chi-square measure. We show that the algorithms outperform other competing algorithms in the runtime, while maintaining a high approximation ratio of more than 0.96.


Motivation
A recent attractive area of research has been the detection of statistically relevant sequences or mining interesting patterns from within a given string [4,11].Given an input string composed of symbols from a defined alphabet set with a probability distribution defining the chance of occurrence of the symbols, and thereby defining its expected composition, we would like to find the portions of the string which deviate from the expected behavior and can thus be potent sources of study for hidden pattern and information.An automated monitoring system like a cluster of sensors sensing the temperature of the surrounding environment for fire alert, or a connection server sniff-ing the network for possible intrusion detection provides a few of the applications where such pattern detection is essential.Other applications involve text analysis of emails and blogs to predict terrorist activities or judging prevalent public sentiments, studying trends of the stock market, and identifying sudden changes in the mutation characteristics of protein sequence of an organism.Similarly, information extracted from a series of Internet websites visited, the advertisements clicked on them or from the nature of transactions on a database, can capture the interests of the end user, prospective clients and also the periods of heavy traffic in the system.An interesting field of application can be the identification of good and bad career patches of a sports icon.For example, given the runs scored by Sachin Tendulkar in each innings of his one-day international cricket career, we may be interested in finding his in-form and off-form patches.
Quantifying a substring or an observation as unexpected under a given circumstance relies on the probabilistic analysis used to model the deviation of the behavior from its expected nature.Such an outcome that deviates from the expected, then becomes interesting and may reveal certain information regarding the source and nature of the variance, and we are interested in detecting such pockets of hidden data within substrings of an input string.A statistical model is used to determine the relationship of an experimental or observed outcome with the factors affecting the system, or to establish the occurrence as pure chance.An observation is said to be statistically significant if its presence cannot be attributed to randomness alone.For example, within a large DNA sequence, the recognition of hugely variational patterns involve probability matching with large fluctuations, thereby the need to predict the locations uses self-consistent statistical procedures [2].
The degree of uniqueness of a pattern can be cap-tured by several measures including the p-value and z-score [7,10].For evaluating the significance of a substring, it has been shown that the p-value provides a more precise conclusion as compared to that by the z-score [4].However, computing the p-value entails enumerating all the possible outcomes, which can be exponential in number, thus rendering it impractical.So, heuristics based on branch-and-bound techniques have been proposed [3].The log-likelihood ratio, G 2 [8] provides such a measure based on the extent of deviation of the substring from its expected nature.For multinomial models, the χ 2 statistic approximates the importance of a string more closely than the G 2 statistic [8,9].Existing systems for intrusion detection use multivariate process control techniques such as Hotelling's T 2 measure [5], which is again computationally intensive.The chi-square measure, on the other hand, provides an easy way to closely approximate the p-value of a sequence [8].To simplify computations, the χ 2 measure, unlike Hotelling's method, does not consider multiple variable relationship, but is as effective in identifying "abnormal" patterns [11].Thus, in this paper, we use the Pearson's χ 2 statistic as a measure of the p-value of a substring [8,9].The χ 2 distribution is characterized by the degrees of freedom, which in the case of a string, is the number of symbols in the alphabet set minus one.The larger the χ 2 value of a string, the smaller is its p-value, and hence more is its deviation from the expected behavior.So, essentially our problem reduces to finding the substring that has the maximum χ 2 value.We propose to extract such substrings efficiently.

Related Work:
Formally, given a string S composed of symbols from the alphabet set Σ with a given probability distribution P modeling the chance of occurrence of each symbol, the problem is to identify and extract the top-k substrings having the maximum chi-square value or the largest deviation within the framework of p-value measure for the given probability distribution of the symbols.Naïvely we can compute the χ 2 value of all the substrings present in S and determine the top-k substrings in O(l 2 ) time for a string of length l (see Algorithm 1).The blocking algorithm and its heap variant proposed in [1], reduce the practical running time for finding such statistically important substrings, but suffers from a high worst-case running time.The number of blocks found by this strategy increases with the size of the alphabet set and also when the probabilities of the occurrence of the symbols are nearly similar.In such scenarios, the number of blocks formed can be almost equal to the length of the given string, thereby degenerating the Algorithm 1 Naïve Algorithm Input: String S with the probability of occurrence of each symbol in the alphabet set.Output: Top-k substrings having the maximum χ 2 value.
1: Extract all the substrings in S. 2: Compute the χ 2 value of all the substrings.3: Return the substrings having the top-k χ 2 value.algorithm to that of the naïve one.The heap variant requires a high storage space for maintaining the separate max and min heap structures and also manipulates a large number of pointers.Further, the algorithm does not easily generalize beyond static input strings, and cannot handle top-k queries.In time-series databases, categorizing a pattern as surprising based on its frequency of occurrence and mining it efficiently using suffix trees has been proposed in [6].However, the χ 2 measure, as discussed earlier, seems to provides a better parameter for judging whether a pattern is indeed interesting.
In this paper, we propose two algorithms, All-Pair Refined Local Maxima Search (ARLM) and Approximate Greedy Maximum Maxima Search (AGMM) to efficiently search and identify interesting patterns within a string.We show that the running time of the algorithms are far better than the existing algorithms with lesser space requirements.The procedures can also be easily extended to work in streaming environments.ARLM, a quadratic algorithm in the number of local maxima found in the input string, and AGMM, a linear time algorithm, both use the presence of local maxima in the string.We show that the approximation ratio of the reported results to the actual is 0.96 or more.Empirical results emphasize that the algorithms work efficiently.
The outline of the paper is as follows: Section 2 formulates the properties and behavior of strings under the χ 2 measure.Section 3 describes the two proposed algorithms along with their runtime complexity analysis.Section 4 shows the experimental results performed on real and synthetic data, before Section 5 concludes the paper.

Definition and Properties
Let str = s 1 s 2 . . .s l be a given string of length l composed of symbols s i taken from the alphabet set Σ = {σ 1 , σ 2 , . . ., σ m }, where |Σ| = m.To each symbol σ i ∈ Σ is associated a p σi (henceforth represented as p i ), denoting the probability of occurrence of that symbol, such that m i=1 p i = 1.Let θ σi,str (henceforth represented as θ i,str ) denote the observed number of the sym-bol σ i in the string str, where σ i ∈ Σ and str ∈ Σ * .
The chi-square value of a string str ∈ Σ * of length l is computed as The chi-square measure thus calculates the deviation of the composition of the string from its expected nature by computing the sum of the normalized square of difference of the observed value of each symbol in the alphabet set from the expected value of occurrence.
Observation 1.Under string concatenation operation (.), for two arbitrary strings a and b drawn from the same alphabet set and probability distribution of the symbols (henceforth referred to as the same universe), the χ 2 measure of the concatenated string is commutative in the order of concatenation.
Proof.It is easy to observe that the lengths of a.b and b.a are the same.Further, the observed values of the different symbols and their probabilities of occurrence are the same in both the concatenated strings.Hence, the χ 2 a.b is equal to χ 2 b.a according to Eq. ( 1).
Lemma 1.The χ 2 value of the concatenation of two strings drawn from the same universe is less than or equal to the sum of the χ 2 values of the individual strings.
Proof.Let a and b be two strings, of length l a and l b respectively.Let a.b form the concatenated string having length (l a + l b ).Using Eq. ( 1), the sum of the chi-square values of the strings is Using θ i,ab = θ i,a + θ i,b and Eqs. ( 2) and (3), we have

Lemma 2. The chi-square value of a string composed of only a single type of symbol increases with the length of the string.
Proof.Let str be a string of length l composed only of the symbol σ j , drawn from the alphabet set Σ. Here, θ i,str = 0, ∀i ∈ {1, 2, . . ., m}, i = j and θ j,str = l, as str consists only σ j .Substituting the values in Eq. ( 1), we have If the length of str is increased by one, by including another σ j , its chi-square value becomes Comparing Eq. ( 5) with Eq. ( 4), we observe that the chi-square value increases, since p i ≥ 0, ∀i ∈ {1, 2, . . ., m}.
With this setting, we now define the term local maxima and describe the procedure for finding such a local maxima within a given string.

Definition 1 (Local maxima). The local maxima is a substring, such that while traversing through it, the inclusion of the next symbol does not decrease the χ 2 value of the resultant sequence.
Let s 1 s 2 . . .s n be a local maxima of length n, where s i ∈ Σ, ∀i.Then the following holds The process of finding the local maxima involves a single scan of the entire string.We consider the first local maxima to start at the beginning of the given string.We keep appending the next symbol to the current substring until there is a decrease in the chi-square value of the new substring.The present substring is then considered to be a local maxima ending at the previous position and the last symbol appended signifies the start of the next local maxima.Thus by traversing through the entire string once, we find all the local maxima present, which takes O(l) time for a string of length l.
As an example, consider the string str = aaaabbba, having Σ = {a, b} with the probability of occurrence of symbol a as 0.2, and that of b as 0.8.Starting from the beginning, we compute the χ 2 value of a to be 4.This is considered to be the starting of a local maxima.Appending the next symbol, the chi-square value of aa increases to 8. Since the score increases, the current local maxima is updated to aa.We keep appending the next symbol into the current maxima.We find that χ 2 aaaa = 16 and χ 2 aaaab = 11.25.As there is a decrease in the chi-square value of the substring after insertion of b, the current local maxima becomes aaaa and the next local maxima is said to begin at b. Repeating this procedure for the entire string str, the local maxima found are aaaa, bbb and a.

Lemma 3. The expected number of local maxima present in a string of length l is O(l).
Proof.From Lemma 2, we can observe that, in a local maxima if the two adjacent symbols are the same, then the chi-square value cannot decrease.Thus the current local maxima may end only when a pair of adjacent symbols are different.We would like to find the expected number of positions in the string where such a boundary may exist.Let us define an indicator variable x i , where x i = 1 if the i th and the (i + 1) th symbols in the string are dissimilar, and gives the expected number of local maxima boundaries for a string of length l.P (x i = 1) denotes the probability of the event x i = 1.Therefore, Hence, the expected number of local maxima is O(l) for a string of length l.
However, practically the number of local maxima will be much less than l, as all adjacent positions of dissimilar symbols may not correspond to a local maxima boundary.Using Eq. ( 6), for m = 2 the maximum number of expected local maxima is (l − 1)/2 and is 2(l − 1)/3 for m = 3, which is obtained by substituting the maximum possible value of P (x i = 1).
We further optimize the local maxima finding procedure by initially blocking the string str, as described in [1], and then searching for the local maxima.This makes the procedure faster and concise.A contiguous sequence of the same symbol is considered to be a block, and is replaced by a single instance of that symbol representing the block.If a symbol is selected, the entire block associated with it is considered to be selected.
The next lemma states that if the inclusion of the symbol representing a block increases the χ 2 value, then the inclusion of the entire block will further increase the χ 2 value.This has been proved in Lemma 3.2.5 and Corollary 3.2.6 on page 35-37 of [1].For completeness, we include a sketch of the proof in this paper.By simple algebraic manipulation, we can show that, Hence, by including the entire block the χ 2 value of the substring will be maximized.
The entire string is now block-ed and the local maxima finding procedure works not with the original str but with aba, where the first a represents the four contiguous a's in str, the b represents the next three b's, and the final a stands for the last occurrence of a.The local maxima thus found are a, b and a.The positions of the local maxima are 1, 5 and 8 respectively, according to their position in the original string.
Given the position of component y for each local maxima of a string, we need to extract the global maxima, which we formally define as follows.
Definition 2 (Global maxima).Global maxima is the substring having the maximum chi-square value, and is the substring that we are interested in extracting, i.e., the output substring.
The global maxima has the maximum score among all possible substrings present in the input string.

Algorithms
Based on the observations, lemmas and local maxima extracting procedure discussed previously, in this section we explain the All-Pair Refined Local Maxima (ARLM) and Approximate Greedy Maximum Maxima (AGMM) search algorithms for mining the most significant substring based on the chi-square value.

All-Pair Refined Local Maxima Search Algorithm (ARLM)
Given a string str of length l and composed of symbols from the alphabet set Σ, we first extract all the local maxima present in it in linear time, as described earlier.We also optimize the local maxima finding procedure by incorporating the idea of the blocking algorithm.With str partitioned into its local maxima, the global maxima can either start from the beginning of a local maxima or from a position within it.Thus, it can contain an entire local maxima, a suffix of it or itself be a substring of a local maxima.It is thus intuitive that the global maxima should begin at a position such that the subsequent sequence of characters offer the maximum chi-square value.Otherwise, we could keep adding to or deleting symbols from the front of such a substring and will still be able to increase its χ 2 value.Based on this, the ARLM heuristic finds within each local maxima the suffix having the maximum chi-square value, and considers the position of the suffix as a potential starting point for the global maxima.
Let xyz be a local maxima, where x is a prefix of length l x , y is a single symbol at position pos, and z be the remaining suffix having length l z .Categorizing the components, namely x, y and z of a local maxima appropriately, is extremely crucial for finding the global maxima.Let start pos and end pos be two lists which are initially empty and will contain the position of component y, i.e., pos, for each of the local maxima.For a local maxima the chi-square value of all its suffices is computed.The starting position of the suffix having the maximum chi-square value provides the position pos for the component y, i.e, yz will be the suffix of xyz having the maximum chi-square value.The position pos is inserted into the list start pos.If no such proper suffix exists for the local maxima, the starting position of the local maxima xyz relative to the original string is inserted in the list.After populating the start pos list with position entries of y for each of the local maxima of the input string, the list contains the prospective positions from where the global maxima may start.
The string str is now reversed and the same algorithm is re-run.This time, the end pos list is similarly filled with positions y ′ relative to the beginning of the string.
For simplicity and efficiency of operations, we maintain a table, symbol count having m rows and l columns, where m is the cardinality of the alphabet set.The rows of the table contain the observed number of each associated symbols present in the length of the string denoted by the column.The observed count of a symbol between two given positions of the string can thus be easily found from this table in O(1) time.The space required in this case becomes O(lm).However, the table reduces the number of accesses of the original string for computing the maximum suffix within each local maxima.It also helps to generalize the algorithm to streaming environments, where it is not possible to store the entire string.

Algorithm 2 ARLM Algorithm
Input: String S with the probability of occurrence of each symbol in the alphabet set.Output: Top-k substrings with the maximum χ 2 value.
1: Find all the local maxima in S and S reversed.2: start pos ← position of suffices with maximum χ 2 value in each local maxima of S. 3: end pos ← position of suffices with maximum χ 2 value in each local maxima of S reversed.4: Based on the χ 2 value, return the top-k substrings formed from all pairs of positions from the two lists.
Given the two non-empty start pos and end pos lists, we now find the chi-square value of substrings from position g ∈ start pos to h ∈ end pos, and g ≤ h.The substring having the maximum value is reported as the global maxima.While computing the chi-square values for all the pairs of positions in the two list, the top-k substrings can be maintained using a heap of k elements (see Algorithm 2 for the pseudo-code).
Continuing with our example of str = aaaabbba, the start pos list contains 1, 5 and 8, as the final local maxima does not contain a proper suffix with a larger chisquare value greater than itself.Computing on str reversed, the end pos list will contain 8, 7 and 4. We now consider the substrings formed by the pairs (1,8), (1,7), (1,4), (5,8), (5,7), and (8,8).Calculating all the chisquare values and comparing them, we find that (1,4) has the maximum value and is reported as the global maxima which is aaaa.Taking k = 2, we find that the substring aaaabbba corresponding to (1,8) provides the second highest chi-square value.Proof.This directly follows from the commutative property stated in Section 2.

Analysis of ARLM
Finding all the local maxima in the string requires a single pass, which takes O(l) time for a string of length l.Let the number of local maxima in the string be d.Finding the maximum valued suffix for each local maxima using the symbol count table, requires another pass of each of the local maxima, and thus also takes O(l) time.Since, each local maximum contributes one position to the lists, the number of elements in both the lists is d.In the rare case that a local maxima contains two or more suffices with the same maximum χ 2 value greater than that of the local maxima, we store all such positions in the corresponding list.Thus, the lists are of O(d) length.We then evaluate the substrings formed by each possible pair of start and end positions, which takes O(d 2 ).So in total, the time complexity of the algorithm becomes O(l + d 2 ).
We justified that although d is of O(l), the expected number of local maxima is far less than that (supported by empirical values shown in Section 4).So although the theoretical running time degenerates to O(l 2 ), practically it is found to be much better.The following optimization further reduces the running time of the algorithm.We evaluate the chi-square values only when the substrings are properly formed from the two lists, i.e., for a given pair of start and end positions obtained from the two lists, the ending position is greater than or equal to the starting position.This further reduces the actual running time required compared to that given by O(d 2 ).We empirically show that the running time is actually 3-4 times less than the naïve algorithm which computes and compares the value of all the possible substrings present in the original string.

Approximate Greedy Maximum Maxima Search Algorithm (AGMM)
In this section, we propose a linear time greedy algorithm for finding the maximum substring, which is linear in the size of the input string str.We extract all the local maxima of the input string and its reverse, and populate the start pos and end pos lists as discussed previously.We identify the local maxima suffix max having the maximum chi-square value among all the local maxima present in the string.AGMM assumes this local maxima suffix to be completely present within the global maxima.We then find a position g ∈ start pos for which the new substring starting at g and ending with max as a suffix has the maximum χ 2 value, for all g.Using this reconstructed substring, we find a position h ∈ end pos such that the new string starting at the selected position g and ending at position h has the maximum chi-square measure for all positions of h.This new substring is reported by the algorithm as the global maxima.Again, using the example of str = aaaabbba, we find max = aaaa and using the two lists, aaaa is returned as the global maxima.For k = 2, the heuristic returns aaaabbba as the second most significant substring.
Using the symbol count table, AGMM takes O(d) time, where d is the number of local maxima found.The Algorithm 3 AGMM Algorithm Input: String S with start pos and end pos lists.Output: Top-k statistically most significant substrings.
1: max ← suffix having the maximum χ 2 value.2: G ← strings starting at positions from start pos with max as suffix.3: H ← strings in G ending at positions from end pos.4: Return the top-k strings of H based on χ 2 value.total running time of the algorithm is O(d + l).However, the substring returned may not be the actual global maxima at all times.The intuition is that the global maxima will contain the maximum of the local maxima to maximize its value.This assumption is justified by empirical results in Section 4, which shows that almost always we obtain an approximation ratio of 0.96 or more, if not the exact value.Being a linear time algorithm, it provides a order of increase in the runtime as compared to the other algorithms.While finding the values of g and h, we can keep a track of the chi-squared values of all the strings thus formed.Using these values, the heuristics can be used to output the top-k substrings (see Algorithm 3 for the pseudo-code).

Experiments
To assess the performance of the two proposed heuristics ARLM and AGMM, we conduct tests on multiple datasets and compare it with the results of the naïve algorithm and the blocking algorithm [1].The heap variant of the blocking algorithm is not efficient as it has a higher running time complexity and uses more memory, and hence has not been compared with.The accuracy of the results returned by the heuristics is compared with that returned by the naïve algorithm, which provides the optimal answer.
We used two real datasets: (i) innings by innings runs scored by Sachin Tendulkar in one-day internationals (ODI) 1 and (ii) the number of user clicks on the front page of msnbc.com 2 .We have also used synthetic data to assess the scalability and practicality of the heuristics.We compare the results based on the following parameters: (i) search time for top-k queries, (ii) number of local maxima found, and (iii) accuracy of the result based on the ratio of the optimal χ 2 value obtained from the naïve algorithm to that returned by the algorithms.The experiments were conducted on a 2.1 GHz desktop PC with 2  GB of memory using C++ in Linux environment.

Real Datasets
Table 1 summarizes the statistics of Sachin Tendulkar's present ODI career.The innings where he did not bat were not considered.Given his runs, we quantized the runs scored into 5 symbols as follows: 0-9 is represented by A (Poor), 10-24 by B (Bad), 25-49 by C (Fair), 50-99 by D (Good) and 100+ by E (Excellent).His inningswise runs were categorized, and from the entire data we calculated the actual probability of occurrences of the different symbols, which were 0.28, 0.18, 0.22, 0.22 and 0.10 respectively for the five symbols.With this setting, we extracted the top-k substring with the maximum chisquare value.These results reflect the periods of his career when he was in top form or when there was a bad patch, since in both cases his performance would deviate from the expected.Table 2 summarizes the findings.We find that during his best patch he had scored 8 centuries and 3 half-centuries in 20 innings with an average of 84.31, while in the off-form period he had an average of 21.89 in 9 innings without a score above 40.Figure 1 and Figure 2 plot the times taken by the different algorithms and the approximation factor or accuracy of result for the heuristics respectively while varying the values of top-k queries.The ARLM algorithm takes lesser running time as compared to the other procedures, while the AGMM method, being a linear time algorithm, is very fast.The accuracy of the ARLM heuristic is found to be 100% for the top-1 query, i.e., it provides the correct result validating the conjecture we proposed in Section 3. As the value of k increases we find an increase in the ap- proximation ratio of both the heuristics as the number of pairs of local maxima involved increases, giving better results.The number of local maxima found is lesser than the number of blocks constructed by the blocking algorithm (see Table 4).So, the heuristic prunes the search space more efficiently.
The second real dataset that we considered contained the number of user clicks encountered on the front page of the website msnbc.comduring various periods of a day taken from a sample of 989819 users.Analysis of the clicks from a group of users provides an insight into potent clients for the organization or customers for ecommerce purposes.The number of clicks have been categorized as follows: 1-3 clicks have been represented by A (Low), 4-9 clicks by B (Medium) and 10+ clicks by C (High).We accordingly quantized the dataset and then performed the experiments by calculating the actual probability of occurrences of the different symbols which were 0.43, 0.36 and 0.21 respectively.Table 3  data values and tabulates the result for the top-1 query.Due to time-consuming nature of this dataset, we did not search for the top-k queries with varying values of k.The results show that the ARLM technique has a better running time than the others, and also operates on a lesser number of local maxima as opposed to the number of blocks for the blocking algorithm (see Table 4).The approximation factor for both the heuristics is 1 for the top-1 search, thereby yielding the correct result.

Synthetic datasets
We now benchmark the ARLM and AGMM heuristics against datasets generated randomly using a uniform distribution.To simulate the deviations from the expected characteristics as observed in real applications, we perturb the random data thus generated with chunks of data generated from a geometric distribution with parameter p = 0.3.These strings are now mined to extract the top-k substrings with largest chi-square values.The parameters that affect the performance of the heuristics are: (i) length of the input string, l, (ii) size of the alphabet set, m, and (iii) number of top-k values.For different values of these parameters we compare our algorithms with the existing ones on the basis of (a) time to search, (b) approximation ratio of the results, and (c) the number of blocks evaluated in case of blocking algorithm to the number of local maxima found by our algorithm.

Effect of parameters
Figure 3 shows that with the increase in the length of the input string l, the time taken for searching the top-k queries increases.increases with the size of the string and hence the time to compute also increases.The time increases more or less quadratically for ARLM and the other existing algorithms according to the analysis shown in Section 3.2.ARLM takes less running time than the other techniques, as the number of local maxima found is less than the number of blocks found by the blocking algorithm (see Table 5).
Hence, it provides better pruning of the search space and is faster.On the other hand, AGMM being a linear time heuristic runs an order of time faster than the others.We also find that the accuracy of the top-k results reported by AGMM show an improvement with the increase in the string length (see Figure 7), as the deviation of substrings become more prominent with respect to the large portions of the string depicting expected behavior.The approximation factor for ARLM is 1 for the top-1 query in all the cases tested, while for other top-k queries and for AGMM it is always above 0.96.
Varying the size of the alphabet set m, we find that the time taken for searching the top-k query as well as the number of blocks formed increases (Table 5 and Figure 4).As m increases, the number of blocks increases as the probability of the same symbol occurring contiguously falls off.We have observed in Section 2 that a local maxima can only end at positions containing adjacent dissimilar symbols.So the number of local maxima found increases, thereby increasing the computation time of the algorithms.There seems to be no appreciable effect of m on the approximation ratio of the results returned by the algorithms.We tested with varying values of m with l = 10 4 and k = 2, and found the ratio to be 1 in all cases.Figure 6 shows the effect of varying probability of occurrence of one of the symbols in a string composed of two symbols only.The approximation ratio remained 1 for both heuristics for the top-1 query.
We next show the scalability of our algorithms by conducting experiments for varying values of k for top-k substrings.Figure 5 shows that search time increases with the increase in the value of k.This is evident as we are required to perform more computations.The accuracy of the results for the heuristics increases with k.For k = 2, it is 0.96, and increases up to 1 when k becomes more than 10.The number of blocks or local maxima found remains unchanged with the variation of k.

Conclusions
In this paper, we have proposed two heuristics for searching a given string for the top-k substrings having the maximum chi-square value representing its deviation from the expected nature, with the possibility of hidden pattern or information.We described how the chi-square measure closely approximates p-value and is apt for mining such substrings.We provided a set of observations based on which we developed two heuristics, one which runs in time quadratic with the number of local maxima, and the other which is linear.Our experiments showed that the proposed heuristics are faster than the existing algorithms.The algorithms return results that an approximation ratio of more than 0.96.

Lemma 4 . 2 p 2 p 2 p e l sub Or, χ 2 sub+1 ≥ χ 2 sub
If the insertion of a symbol of a block increases the chi-squared value of the current substring, then the chi-squared value will be maximized if the entire block is inserted.Proof.Let the current substring be sub and the adjacent block of length n be composed of symbol σ e ∈ Σ. Appending one σ e to sub increases the χ 2 value of the new substring.Given, m i=1,i =e (p i (l sub + 1) − θ i,sub+1 ) 2 p i (l sub + 1) + (p e (l sub + 1) − θ e,sub+1 ) e (l sub + 1) ≥ m i=1,i =e (p i l sub − θ i,sub ) i l sub + (p e l sub − θ e,sub )

Conjecture 1 .Corollary 1 .
The starting position of the global maxima is always present in the start pos list.From the above conjecture, it follows that the ending position of the global maxima is also present in the end pos list.

Figure 1 :Figure 2 :
Figure 1: Time for finding the top-k query in Sachin's run dataset.

Figure 3 :
Figure 3: Effect of length on search time.

Figure 4 :Figure 5 :
Figure 4: Effect of size of alphabet size on search time.

Figure 6 :Figure 7 :
Figure 6: Effect of probability in two symbol string on search time.

Table 3 :
describes the Results for dataset (containing 989819 records) of number of user clicks.

Table 4 :
Number of blocks versus local maxima for real datasets.

Table 5 :
The number of blocks or local maxima Results for uniform dataset.