Testing of sequences by simulation

Reading time: 6 minute
...

📝 Original Info

  • Title: Testing of sequences by simulation
  • ArXiv ID: 1012.0032
  • Date: 2015-03-17
  • Authors: Researchers from original ArXiv paper

📝 Abstract

Let $\xi$ be a random integer vector, having uniform distribution \[\mathbf{P} \{\xi = (i_1,i_2,...,i_n) = 1/n^n \} \ \hbox{for} \ 1 \leq i_1,i_2,...,i_n\leq n.\] A realization $(i_1,i_2,...,i_n)$ of $\xi$ is called \textit{good}, if its elements are different. We present algorithms \textsc{Linear}, \textsc{Backward}, \textsc{Forward}, \textsc{Tree}, \textsc{Garbage}, \textsc{Bucket} which decide whether a given realization is good. We analyse the number of comparisons and running time of these algorithms using simulation gathering data on all possible inputs for small values of $n$ and generating random inputs for large values of $n$.

💡 Deep Analysis

Deep Dive into Testing of sequences by simulation.

Let $\xi$ be a random integer vector, having uniform distribution [\mathbf{P} {\xi = (i_1,i_2,…,i_n) = 1/n^n } \ \hbox{for} \ 1 \leq i_1,i_2,…,i_n\leq n.] A realization $(i_1,i_2,...,i_n)$ of $\xi$ is called \textit{good}, if its elements are different. We present algorithms \textsc{Linear}, \textsc{Backward}, \textsc{Forward}, \textsc{Tree}, \textsc{Garbage}, \textsc{Bucket} which decide whether a given realization is good. We analyse the number of comparisons and running time of these algorithms using simulation gathering data on all possible inputs for small values of $n$ and generating random inputs for large values of $n$.

📄 Full Content

Let ξ be a random integer vector, having uniform distribution P{ξ = (i 1 , i 2 , . . . , i n )} = 1/n n for 1 ≤ i 1 , i 2 , . . . , i n ≤ n.

A realization (i 1 , i 2 , . . . , i n ) of ξ is called good, if its elements are different. We present six algorithms which decide whether a given realization is good.

This problem arises in connection with the design of agricultural [4,5,57,72] and industrial [34] experiments, with the testing of Latin [1,9,22,23,27,32,53,54,63,64] and sudoku [3,4,6,12,13,14,15,16,17,20,21,22,26,29,30,31,41,42,44,46,47,51,55,59,61,64,66,67,68,69,70,72,74] squares, with genetic sequences and arrays [2,7,8,18,24,28,35,36,37,38,45,48,49,50,56,65,71,73,75], with sociology [25], and also with the analysis of the performance of computers with interleaved memory [11,33,39,40,41,43,52].

Section 2 contains the pseudocodes of the investigated algorithms. In Section 3 the results of the simulation experiments and the basic theoretical results are presented. Section 4 contains the summary of the paper.

Further simulation results are contained in [62]. The proofs of the lemmas and theorems can be found in [43].

This section contains the pseudocodes of the investigated algorithms Linear, Backward, Forward, Tree, Garbage, and Bucket. The psudocode conventions described in the book [19] written by Cormen, Leiserson, Rivest, and Stein are used.

The inputs of the following six algorithms are n (the length of the sequence s) and s = (s 1 , s 2 , . . . , s n ), a sequence of nonnegative integers with 0 ≤ s i ≤ n for 1 ≤ i ≤ n) in all cases. The output is always a logical variable g (its value is True, if the input sequence is good, and False otherwise).

The working variables are usually the cycle variables i and j.

Linear writes zero into the elements of an n length vector v = (v 1 , v 2 , . . . , v n ), then investigates the elements of the realization and if v[s i ] > 0 (signalising a repetition), then stops, otherwise adds

Linear(n, s)

Backward compares the second (i 2 ), third (i 3 ), . . . , last (i n ) element of the realization s with the previous elements until the first collision or until the last pair of elements.

Backward(n, s)

return g 07 return g

Forward compares the first (s 1 ), second (s 2 ), . . . , last but one (s n-1 ) element of the realization with the following elements until the first collision or until the last pair of elements.

return g 07 return g

Tree builds a random search tree from the elements of the realization and finishes the construction of the tree if it finds the following element of the realization in the tree (then the realization is not good) or it tested the last element too without a collision (then the realization is good).

This algorithm is similar to Linear, but it works without the setting zeros into the elements of a vector requiring linear amount of time.

Beside the cycle variable i Garbage uses as working variable also a vector v = (v 1 , v 2 , . . . , v n ). Interesting is that v is used without initialisation, that is its initial values can be arbitrary integer numbers.

The algorithm Garbage was proposed by Gábor Monostori [58].

Garbage(n, s)

Bucket handles the array Q[1 : m, 1 : m] (where m = ⌈ √ n⌉ and puts the element s i into the rth row of Q, where r = ⌈s i /m⌉ and it tests using linear search whether s j appeared earlier in the corresponding row. The elements of the vector c = (c 1 , c 2 , . . . , c m ) are counters, where c j (1 ≤ j ≤ m) shows the number of elements of the ith row.

For the simplicity we suppose that n is a square.

3 Analysis of the algorithms

The first algorithm is Linear. It writes zero into the elements of an n length vector v = (v 1 , v 2 , . . . , v n ), then investigates the elements of the realization sequentially and if i j = k, then adds 1 to v k and tests whether v k > 0 signalizing a repetition.

In best case Linear executes only two comparisons, but the initialization of the vector v requires Θ(n) assignments. It is called Linear, since its running time is Θ(n) in best, worst and so also in expected case.

Theorem 1 The expected number C exp (n, Linear) = C L of comparisons of Linear is

where

tends monotonically decreasing to zero when n tends to infinity. n!/n n also tends monotonically decreasing to zero, but their difference δ(n) = κ(n)n!/n n is increasing for 1 ≤ n ≤ 8 and is decreasing for n ≥ 8.

The expected running time T exp (n, Linear) = T L of Linear is

n n tends to zero when n tends to infinity, further

Table 1 shows some concrete values connected with algorithm Linear.

The second algorithm is Backward. This algorithm is a naive comparisonbased one. Backward compares the second (i 2 ), third (i 3 ), . . . , last (i n ) element of the realization with the previous elements until the first repetition or until the last pair of elements.

The running time of Backward is constant in the best case, but it is quadratic in the worst case.

where α(n) = κ(n)/2 + (n!/n n )((n + 1)/2) monoto

…(Full text truncated)…

📸 Image Gallery

cover.png

Reference

This content is AI-processed based on ArXiv data.

Start searching

Enter keywords to search articles

↑↓
ESC
⌘K Shortcut