Abstract:
A pattern matching system comparing two patterns A and B, at least one of which is compressed in accordance with a piecewise straight line approximation and is represented by a series of representative vectors, of fewer number than the uncompressed pattern, and a series of extraction points of the representative vectors from the compressed pattern. First a distance is calculated between a segment of the compressed pattern and a point of the second pattern. Also a weighting coefficient is calculated depending on the length of the segment. From the latter two calculations three weighted distances are calculated appropriate to a recursion formula. The recursion formula is integrated by step wise incrementing the indices corresponding to the points of the two pattern. The final value of the recursion calculation is normalized to produce the final composite distance between the two patterns.

Description:
BACKGROUND OF THE INVENTION 
     This invention relates to a pattern matching system for comparing two patterns each given as a series of feature vectors like a voice pattern. 
     A pattern matching process wherein an incoming unknown pattern is compared with a plurality of dictionary patterns being previously registered and the one dictionary pattern with the highest similarity is determined as the incoming unknown pattern has been generally applied as an available method for pattern recognition. 
     It is essential for the pattern matching process to cope with variations, such as changes in speaking speed in a voice pattern. A time normalizing matching process (DP process) employing a dynamic programming process such as disclosed, for example, in U.S. Pat. Nos. 4,059,725 and 4,326,101 will be exceedingly effective. However, in the matching process, since a pattern to be matched should be expressed by a time series of feature vectors sampled at a predetermined constant period, a storage requirement for storing the feature vectors will inevitably increase to store a long voice pattern, and the amount of processing required will also increase. To overcome such problems, a compressed DP process is utilized wherein representative vectors are sampled at nonuniform sampling periods where there is present a stationary part in a pattern, like a vowel part of the voice pattern. Applying the DP process to a series of the representative vectors is proposed in the U.S. patent application Ser. No. 353,293 filed on Mar. 1, 1982. 
     However, in the compressed DP process, a data quantity is not compressed at a transition part in which the pattern changes, and the interval between a representative vector and succeeding representative vector is approximated retangularly, therefore an approximation error from the original pattern will be unavoidable. Then, by approximating the original pattern in a connection of straight line segments, i.e., piecewise straight line segment and extracting the connecting point as a representative vector, the data is compressed even at the transition part in which the pattern changes, and the approximation error from the original pattern is minimized, thus realizing a high precision of matching with less storage and computation requirements. In this case, however, the extracted representative vector has not already represented a section according to an original pattern, but a segment connecting the two adjacent representative vectors represents a section of the original pattern. In this respect, therefore, the conventional compressed DP matching process using the distance between the representative vector of a pattern A and the representative vector of a pattern B for matching of the two patterns A and B is not applicable when representative vectors are given as connecting points of the line segment. 
      SUMMARY OF THE INVENTION 
     It is, therefore, an object of the present invention to provide a new pattern matching system which is capable of using DP process when at least one of an input pattern and a dictionary pattern is approximated by a piecewise straight line segment, and which, accordingly, requires less storage capacity and a simpler circuit configuration. 
     The invention can be summarized as an apparatus for calculating a distance (a measure of similarity) between two patterns, each pattern represented by a series of vectors. In a first embodiment, one of the patterns is compressed by retaining only some of the vectors, that is, the pattern is represented by a series of straight lines of unequal lengths. In a second embodiment, both of the patterns are compressed. Perpendicular distances are calculated between the vectors of one pattern and the straight lines of the other pattern which has been compressed. Three different weights are calculated which depend upon the length of the straight line segment. These weights are appropriate to a recursion relation. The recursion relation is solved by stepping through the indices corresponding to the numbering of the retained vectors in the two patterns from the origin on one side to the extreme indices on the other side. The thus integrated recursion relationship, properly normalized, represents the composite distance between the two patterns and thus provides a numerical comparison of the two patterns. 
     According to one aspect of this invention, as described in detail, there is provided a pattern matching system comprising a first vector memory unit to store a series {a(1), . . . , a(k), . . . , a(K)} of representative vectors obtainable through extracting a representative vector from the first pattern A given as a series of feature vectors when one pattern is compressed in piecewise straight line approximation and a series of extraction points {P(1), . . . , P(k), . . . , P(K)}, a second vector memory unit to store the second pattern B{b(1), . . . b(l), . . . , b(L)} given as a series of feature vectors, a distance calculating unit to calculate a distance d(l, k) between a line segment connecting representative vectors a(k) and a(k-1) in the vector space and a feature vector b(l) in accordance with an address signal (l, k), a weighted distance calculating unit to calculate a weighted distance according to a weight coefficient determined from a difference ΔP(k)(=P(k)-P(k-1)) between extraction points P(k) and P(k- 1) and the distance d(l, k), and a matching unit to calculate a distance between the patterns A and B by considering a group of weighted distances obtained through changing the address signal (l, k) to k=1, . . . , K, l=1, . . . , L. 
     According to such an arrangement as mentioned, a reference dictionary pattern can be compressed not only for the stationary part but also for the transition part, and further an error derived from the compression can be minimized, therefore a high time normalizing ability of the dynamic programming process can be brought into full play, and thus a low-cost and high performance pattern recognition system is obtained. 
     According to another aspect of this invention, by compressing both patterns in piecewise straight line, there is provided a pattern matching system comprising a first vector memory unit to store a series {a(1), . . . , a(i), . . . , a(I)} of representative vectors obtained through extracting a representative vector from the first pattern A given as a series of feature vectors and a series {P(1), . . . , P(i), . . . , P(I)} of extraction points, a second vector memory unit to store a series {b(1), . . . , b(j), . . . , b(J)} of representative vectors obtained through extracting a repesentative vector from the second pattern B given as a series of feature vectors and a series {q(1), . . . , q(j), . . . , q(J)} of extraction points, a distance calculating unit responsive to specified i, j to calculate a distance d A  (i, j) between a line segment connecting representative vectors a(i+1) and a(i) and a point corresponding to the representative vector b(j) and a distance d B  (i, j) between a segment connecting the representative vectors b(j+1) and b(j) and a point corresponding to the representative vector a(i), a distance memory unit to store at least a predetermined number of distance data arrayed in a lattice which is obtained through changing i and j sequentially when the distance d A  (i, j) is assigned with a side connecting points (i, j) and (i+1, j) and the distance d B  (i, j) is assigned with a side connecting points (i, j) and (i, j+1) on the I×J lattice composed by I and J time points, an integral memory unit to store at least a predetermined number of integral value g of the distances to points and sides of the lattice, a recurrence formula calculating unit to calculate the integral value g at each point and side of the lattice through a plural combination of the weighted sum of the integral value previously stored in the integral memory unit and the distance previously stored in the distance memory unit, thereby obtaining the minimum integral value, which is characterized in that a distance between the patterns A and B is calculated by shifting i and j sequentially from i=1 and j=1 to i=I and j=J. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1(a) shows an original pattern A and FIG. 1(b) shows the approximated pattern A&#39; of the pattern A in a piecewise straight line; 
     FIG. 2(a) and FIG. 2(b) are diagrams for explaining a recurrence formula to determine integral value; FIG. 2(a) corresponds to the recurrence formula to determine the integral value between the approximated pattern A&#39; and an original pattern B, and FIG. 2(b) corresponds to the recurrence formula to determine the integral value between the original patterns A and B; 
     FIG. 3 is a block diagram of a first embodiment of the present invention; 
     FIG. 4 is a block diagram of a distance calculating unit shown in FIG. 3; 
     FIGS. 5(a), 5(b) and 5(c) show conception of distances determined by the distance calculating unit shown in FIG. 4; 
     FIG. 6 is a block diagram of a processing unit shown in FIG. 4; 
     FIG. 7 is a block diagram of a matching unit shown in FIG. 3; 
     FIG. 8 is a diagram for explaining distances determined between two patterns; 
     FIGS. 9(a), 9(b) and 9(c) are diagrams for explaining a matching process; 
     FIG. 10 is a diagram for explaining distances between two patterns in a second embodiment of the present invention; 
     FIGS. 11(a), 11(b) and 11(c) are diagrams indicating a part of the diagram shown in FIG. 10 for explaining the recurrence formula according to the second feature of the present invention; and 
     FIG. 12 is a block diagram of the second embodiment of the present invention. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     A first embodiment of the present invention will be described hereinafter. In this embodiment, only one of two patterns is approximately compressed and a matching operation is performed by using a distance between a segment connecting two points corresponding to two adjacent representative vectors of the compressed pattern and a point corresponding to the vector of the other pattern. 
     Assume that two patterns A and B are expressed by series of feature vectors: 
     
         A={a(1), a(2), . . . , a(J)} 
    
     
         B={b(1), b(2), . . . , b(L)} 
    
     Then, when the pattern A is compressed in piecewise straight approximation, the series of representative vectors obtained as connecting points is expressed as pattern A&#39;: 
     
         A&#39;={a&#39;(1), . . . , a&#39;(K)} 
    
     Further, a distance d(l, k) between a segment connecting two points each corresponding to two vectors a&#39;(k-1) and a&#39;(k), respectively, and a point corresponding to the vector b(l) is defined by d(l, k). The distance d o  between a straight line connecting two points x 1  and x 2  and a point y in Euclidian space is obtained as follows. ##EQU1## Therefore, this equation is utilized to obtain the distance d(l, k). The distance between the pattern A&#39; and the pattern B is calculated by using a dynamic programming process. Thus, the calculation of a recurrence formula (1) is provided for the dynamic programming process. ##EQU2## The integral value g(l, k) defined by the formula (1) is sequentially calculated in the range of 2≦k≦K and 1≦l≦L, starting from the initial condition g(1, 1)=0. Finally, the integral value g(L, K) is derived and a distance D is calculated as the distance between the patterns A&#39; and B. 
     
         D=g(L, K)/(L+K-1)                                          (2) 
    
     However, the section length in the original pattern A is not equal to the length of the corresponding segment in the pattern A&#39;, and hence it is not taken into consideration in the recurrence formula (1). 
     FIGS. 1(a) and (b), which show the pattern A and the approximated pattern A&#39;, respectively, are provided for explaining such case. In FIG. 1(b), while the section (a&#39;(4), a&#39;(5)) covers a major part of the pattern, it is weighted equivalently to the section (a&#39;(2), a&#39;(3)) when the distance is integrated by the formula (1), thus being evaluated too lightly. Such problem can be overcome by weighting the distance d(l, k) by a segment length corresponding to the piecewise straight line when the pattern A is subjected to a piecewise straight line approximation. In other words, where an extraction point of the representative vector a&#39;(k) is given, for example, at a point P(k) in the pattern A&#39;, the weighting to a segment connecting the representative vectors a&#39;(k-1) and a&#39;(K) can be determined by 
     
         ΔP(k)=P(k)-P(k-1) 
    
     and the following recurrence formula can be used instead of the formula (1): ##EQU3## The recurrence formula (1)&#39; means path and weighting shown in FIG. 2(a). When matching path of the patterns A and B before compression is considered particularly therefor, it implies a move from the positions with a double circle to the position with Δ mark in the drawing by means of path and weighting shown in FIG. 2(b). In the drawing, j, k and l denote time bases of the patterns A, A&#39; and B, respectively. 
     In the first feature of this invention, matching of two patterns one of which is compressed in piecewise straight line approximation is realizable according to DP process including weighting as mentioned above, therefore a pattern matching system requiring less memory and fewer computations, yet having high precision will be obtained. 
     Referring to FIG. 3, a series of representative vectors {a&#39;(1), . . . , a&#39;(K)} of a pattern A&#39; obtained by compressing the pattern A piecewise straight line approximation and a series of extraction points {P(1), . . . , P(K)} of the representative vectors are stored in a first vector memory unit 1. A series of feature vectors {b(1), . . . , b(L)} of a pattern B is stored in a second vector memory unit 2. A distance calculating unit 3 calculates a distance in a vector space, between a segment connecting vectors a&#39;(k-1) and a&#39;(k) and a point corresponding to a vector b(l). These vectors a&#39;(k-1), a&#39;(k) and b(l) are read out from the memory units 1 and 2 in accordance with an address signal (l, k). 
     Referring to FIGS. 4, 5 and 6, the distance calculation will be explained hereinafter. Initially, two patterns A&#39; and B are defined as: 
     
         A&#39;={a&#39;(1), . . . , a&#39;(k), a&#39;(k+1), . . . } 
    
     
         B={b(1), . . . , b(l), b(l+1), . . . } 
    
     In FIG. 4, the pattern A&#39; including time serial vectors is inputted to an input buffer unit 31 and the pattern B including time serial vectors is inputted to an input buffer unit 32. Assuming, now, vectors a&#39;(k) and a&#39;(k+1) are stored in the input buffer unit 31 and the vector b(l) in the input buffer unit 32, an equation 
     
         D=d(a&#39;(k+1), a&#39;(k))                                        (3) 
    
     is calculated by a distance calculating unit 33. The above distance d(a&#39;(k+1), a&#39;(k)) then expresses a square of Euclidian distance in the vector space between the vectors a&#39;(k+1) and a&#39;(k). 
     On the other hand, equations 
     
         X=d(a&#39;(k+1), b(l)                                          (4) 
    
     
         Y=d(a&#39;(k), b(l))                                           (5) 
    
     are calculated in a distance calculating unit 34, and outputs D, X and Y are all outputted to a processing unit 35. In the processing unit 35, a distance between a segment line P(a&#39;(k+1)) P(a&#39;(k)) and a point P(b(l)) is calculated as follows. Here, P(a&#39;) denotes a point corresponding to a vector a&#39;. 
     A square Z of the length of a perpendicular line coming onto the straight line P(a&#39;(k+1)) P(a&#39;(k)) from the point P(b(l)) is represented by ##EQU4## where a&#39;(k+1)≠a&#39;(k). Then, a mark &#34;,&#34; in the equation (6) represents a transposition of the vector. 
     By substituting the equations (3), (4) and (5) into the equation (6), 
     
         Z={XY-1/4(X+Y-D).sup.2 }/D                                 (7) 
    
     A square e of the distance between the segment P(a&#39;(k+1)) P(a&#39;(k)) and the point P(b(l)) is defined as follows by using the equation (7). 
     
         ______________________________________Where D = 0             e = X    (8)Where D ≠ 0 and -D ≦ X - Y ≦ D                   e = Z    (9)Where D ≠ 0 and X - Y &lt; -D                   e = X   (10)Where D ≠ 0 and X - Y &gt; D                   e = Y   (11)______________________________________ 
    
     Conditions of the equation (9), (10) and (11) correspond to the cases where relationship between the segment P(a&#39;(k+1)) P(a&#39;(k)) and the point P(b(l)) are shown in FIGS. 5(a), 5(b) and 5(c), respectively. 
     In the processing unit 35 shown in FIG. 6, data X, Y and D sent from the processing units 33 and 34 are stored in registers 51, 52 and 53, respectively. A processing unit 54 calculates the output Z by the equation (7) in response to the input data D, X and Y, and a determining unit 55 compares the data D, X and Y to determined one of conditions each corresponding to the equations (8) to (11). A selector 56 then outputs one of the data X, Y and Z according to the selection control signal delivered from the determining unit 55. 
     Turning to FIG. 3 again, a calculating unit 4 calculates weighting coefficients ΔP(k)(=P(k)-P(k-1)) and ΔP(k)+1 from the extraction points P(k), P(k-1) read out of the memory unit 1 to apply to the recurrence formula (1)&#39;. A calculating unit 5 produces distances d(1), d(2) and d(3) which are weighted with the weighting coefficient produced at the unit 4 to the distance d(l, k) delivered from the distance calculating unit 3. 
     d(1)=d(l, k) 
     d(2)=P(k)d(l, k) 
     d(3)=(ΔP(k)+1)d(l, k)) 
     The distances d(1), d(2) and d(3) are sent to a matching unit 6. 
     With an initial address signal (l, k)(=1, 1)) the matching unit 6 controls the distance calculating unit 3 and the weighting coefficient calculating unit 4 according to the address signal (l, k) to make them produce the distance d(l, k) and the weighted distances d(1), d(2) and d(3). Further, the matching unit 6 receives the weighted distances d(1), d(2) and d(3), and calculates an integral value g(l, k) by a recurrence formula (1)&#34; and by using the weighted distances d(1), d(2) and d(3), and previously produced integral values g(l-1, k), g(l, k-1) and g(l-1, k-1) with an initial integral value g(1, 1)(=0). ##EQU5## The address signal (l, k) is shifted under the control of the matching unit 6 from l=1, k=1, to l=L, k=K, and a distance D between two patterns 
     
         D=g(L, K)/(L+J-1)                                          (2)&#39; 
    
     
         Where J=P(K)-P(1)+1 
    
     is finally calculated at the address of l=L, k=K and outputted. Then, the equation (2)&#39; is that of which K in the expression (2) is replaced with J, i.e. the length of pattern A&#39; is replaced with that of pattern A before compression. 
     FIG. 7 is a block diagram of the matching unit 6 shown in FIG. 3. In the drawing, registers 66, 67, 68 temporarily store integral values g(l-1, k), g(l, k-1) and g(l-1, k-1), which are on the right side of the recurrence formula (1)&#34;, respectively. A control unit 74 controls overall behavior of matching unit 6 by shifting the address signals (l, k), and after the registers 66, 67 and 68 are initialized the address (l, k) is increased successively. Adders 69, 70 and 71 add the weighted distances d(1), d(2) and d(3) and the values stored in the registers 66, 67, 68, respectively, and output results thus obtained. A minimum value determining unit 72 determines the minimum value among the three outputs of the adders 69, 70, 71, i.e., the integral value g(l, k) defined by the recurrence formula (1)&#34; and outputs a result thus obtained. The result is stored in an integral buffer memory 62 and particulary in a location designated by the address (l, k). Control units 63, 64 and 65 read out the integral values g(l-1, k), g(l, k-1) and g(l-1, k-1) from the buffer memory 62 in according to the address (l, k) and write them in the registers 66, 67 and 68. A output unit 73 divides an output of the minimum value determining unit 72, which is obtained at the time point of the address signal (L, K) i.e., g(L, K), by the pattern length as defined by the equation (2), and thus outputs the matching distance D. 
     In the first embodiment of the present invention as described above, the recurrence formula (1)&#39; is applied. Furthermore, a recurrence formula ##EQU6## or another recurrence formula similar thereto can be used instead of the formula (1)&#39;. 
     Next, a second embodiment according to the second feature of the present invention will be described hereinafter. Now, a series of representative vectors extracted as connecting points when feature vectors of the two patterns A and B are both compressed in piecewise straight line approximation is expressed as 
     
         A={a(1), . . . , a(i), . . . , a(I)} 
    
     
         B={b(1), . . . , b(j), . . . , b(J)} 
    
     and a series of extraction points of representative vectors of the pattern A and B is expressed as 
     
         P={p(1), . . . , p(i), . . . , p(I)} 
    
     
         Q={q(1), . . . , q(j), . . . , q(J)} 
    
     In this case, a distance between the patterns A and B is obtained by using the recurrence formula (1) of conventional DP matching. Namely, with the initial condition given at g(1, 1)=d(1, 1), a calculation of a recurrence formula ##EQU7## is carried out sequentially from i=1 and j=1 to i=I and j=J, where d(i, j) denotes the distance measured between a(i) and b(j). The distance D between the patterns A and B is obtained from g(I, J) finally calculated. 
     
         D=g(I, J)/(I+J-1) 
    
     This procedure thus includes a matching process between two patterns by matching representative points (representative vectors) of the two patterns with each other as shown in FIG. 9(a). 
     Consider the case of two patterns A and B shown in FIG. 9(b), where the distance between a point b3 and a segment a 2  a 3  and the distance between a point b 4  and a segment a 2  a 3  are short, and the distance between a segment b 3  b 4  and a point a 2  and the distance between the segment b 3  b 4  and a point a 3  are long. In this case, if the aforementioned method is applied, any matching path from the point (2,2) to the point (3,5) on the lattice causes a large integrated value in spite of the fact that the patterns A and B are similar, because d(2,3), d(3,3), d(4,2) and d(4,3) have large values. Such a problem can be overcome by letting the representative point of the one pattern correspond with a segment connecting representative points of the other pattern instead of letting the point correspond with a point of the other pattern. This treatment equivalently means matching a line segment of the one pattern with a sequence of line segments of the other pattern. For example, in FIG. 9(b), the segment a 2  a 3  can correspond with a line segment series b 2  b 3 , b 3  b 4  and b 4  b 5 . A matching process adopting such treatment can be realized by introducing distances d A  (i, j) and d B  (i, j) between a segment connecting adjacent representative vectors in the series of representative vectors of the one pattern and the representative vectors of the other pattern are defined instead of the distance d(i, j). 
     
         d.sub.A (i, j)=dist(b(j), a(i-1)a(i)) 
    
     
         d.sub.B (i, j)=dist(a(i), b(j-1)b(j))                      (13) 
    
     In the equation (13), the notation a(i-1)a(i) represents a line segment connecting two points corresponding to the respective vectors a(i-1) and a(i) in the vector space, and the notation dist (b(j),a(i-1)a(i)) represents the distance between the point corresponding to the vector b(j) and the line segment a(i-1)a(k). The distances d A  (i, j) and d B  (i, j) are obtained by an equation of the same sort as equation (6). The distances d A  (i, j) and d B  (i, j) defined by the equation (13) with respect to i=1, . . . , I and j=1, . . . , J can be assigned on each side of a lattice M as shown in FIG. 8. An integral value g can be defined not only at each lattice point on the lattice M but also at each side of it 
     As shown in FIG. 10, a lattice M&#39; of size (2&#39;I-1)×(2J&#39;-1) will be used instead of the lattice M. In the lattice M&#39;, a lattice point (i&#39;, j&#39;) corresponds to the lattice point (i, j) of the lattice M when i&#39;=2i-1 and j&#39;=2j-1, i.e., both i&#39; and j&#39; are odd. When i&#39;=2i and j&#39;=2j-1, i.e., i&#39; is even and j&#39; is odd, the lattice point (i&#39;, j&#39;) corresponds to the side connecting points (i+1, j) and (i, j) of the lattice M. When i&#39;=2i-1 and j&#39;=2j, i.e., i&#39; is odd and j&#39; is even, it corresponds to the side connecting points (i, j+1) and (i, j). When i&#39;=2i, j&#39;=2j, i.e., both i&#39; and j&#39; are even, the point (i&#39;, j&#39; ) does not exist. In the lattice M&#39;, distances d A  (i, j) and d B  (i, j) are assigned with lattice points on M&#39; as follows. When a distance corresponding to a point (i&#39;, j&#39;) on the lattice M&#39; is represented by d&#39;(i&#39;, j&#39;), 
     
         d&#39;(2i, 2j-1)=d.sub.A (i,j), i=1, . . . , I-1, j=1, . . . J 
    
     
         d&#39;(2i-1, 2j)=d.sub.B (i,j), i=1, . . . , I, j=1, . . . , J-1 (14) 
    
     and as weighting coefficients to the distance: 
     
         W&#39;.sub.A (2i)=W.sub.A (i) 
    
     
         W&#39;.sub.B (2j)=W.sub.B (j)                                  (15) 
    
     provided that weights 
     
         W.sub.A (i)=p(i+1)-p(i), W.sub.B (j)=q(j+1)-q(j)           (16) 
    
     are used. FIG. 10 shows the structure of the lattice M&#39;. 
     In the drawing, the double circle indicates a point for which the distance is defined. 
     Under the condition as mentioned above, when an integral value g(i&#39;,j&#39;) similar to the recurrence formula (12) is assumed for to the point (i&#39;, j&#39;) on the lattice M&#39;, the following recurrence formula can be used for the integral value g: 
     Initial value g(1, 1)=0 
     When i&#39; and j&#39; are odd both, ##EQU8## 
     When i&#39; is odd and j&#39; is even, ##EQU9## 
     When i&#39; is even and j&#39; is odd, ##EQU10## The formulas (17-1), (17-2) and (17-3) corresponds to paths and weights shown in FIG. 11(a), 11(b) and 11(c), respectively. 
     The recurrence formulas (17-1) to (17-3) are calculated in sequence from i&#39;-1 and j&#39;=1 to i&#39;-I&#39;(=2I-1) and j&#39;=J&#39;(=2J-1), and, thus, the integral value g(I&#39;,j&#39;) is obtained finally. Dividing the integral value g(I&#39;, J&#39;) by the sum of the lengths of the two original patterns A and B, a distance between the two patterns A and B is obtained as 
     
         D=g(I&#39;,J&#39;)/(I°+J°-1)                         (18) 
    
     where 
     
         I°=p(I)-p(1), 
    
     
         J°=q(J)-q(1). 
    
     Referring to FIG. 12 showing a second embodiment of this invention, a representative vector series {a(1), . . . , a(i), . . . , a(I)} of a first pattern A obtainable through compression in the piecewise line approximation and an extraction point series {p(1), . . . , p(I)} of the representative vectors are stored in a first vector memory unit 101. A representative vector series {b(1), . . . , b(j), . . . , b(J)} of the second pattern B and an extraction point series {a(1), . . . , a(J)} of the representative vectors are stored in a second vector memory unit 102. A distance calculating unit 300 calculates distances d A  (i,j) and d B  (i,j) defined by the recurrence formula (13) in response to i and j specified by a control unit 107 and also calculates weighting coefficients W A  (i) and W B  (j) defined by the equation (16). 
     In the distance calculating unit 300, control units 301 and 302 read out feature vectors a(i-1), a(i), b(j-1) and b(j) and extraction points p(i-1), p(i), q(j-1) and q(j), which are used for the calculation of distances d A  (i,j) and d B  (i,j) and weighting coefficients W A  (i) and W B  (j), from the memory units 101 and 102. A distance calculator 303 calculates the distance d A  (i,j) responsive to the read vectors a(i-1), a(i) and b(j). A distance calculator 304 also calculates the distance d B  (i,j) likewise. A write controller 305 controls to store a value of the distances, as a distance, d&#39; calculated by the distance calculators 303 and 304 into a distance memory 104. In this case, the write controller 305 specifies a write-location in the distance memory 104 according to the equation (14). The distance calculation at the distance calculators 303 and 304 can be done as in the case of the distance calculation in the first embodiment. Calculators 306 and 307 calculate the weighting coefficients W A  (i) and W B  (j) defined by the equation (16), respectively. Values thus obtained are stored in a weight memory 105 under the control of a write controller 308 as W&#34; A  and W&#34; B . 
     In this case, the write controller 308 specifies a write-location according to the equation (15). 
     A control signal converter 108 converts control signals i and j in to three ways as: 
     
         (i&#39;, j&#39;)=(2i-2, 2j-1) 
    
     
         (i&#39;, j&#39;)=(2i-1, 2j-2) 
    
     
         (i&#39;, j&#39;)=(2i-1, 2j-1) 
    
     and outputs them as control signals i&#39; and j&#39;. An recurrence formula calculating unit 900 obtains an integral value g(i&#39;, j&#39;) responsive to the specified control signal i&#39; and j&#39; by calculating the formulas (17-1) to (17-3). In this case, distance information necessary for the calculation of the formulas (17-1) to (17-3) is read out from the distance memory 104 and the weight memory 105, the previously calculated integral value g is read out from an integral memory 106, and the integral value g(i&#39;,j&#39;) thus obtained is stored in the integral memory 106 again. 
     The calculation of the recurrence formulas (17-1) to (17-3) is carried out as follows: Read controllers 901, 902 and 905 specify read-locations in the distance memory 104, the weight memory 105 and the integral memory 106, respectively. 
     First, where the control signal (i&#39;,j&#39;) is 
     
         (i&#39;, j&#39;)=(2i-2, 2j-1) 
    
     the recurrence formula (17-3) is calculated as follows: The read controllers 901, 902 and 905 read out the distance d&#39;(i&#39;,j&#39;), the weighting coefficient W A  &#39;(i&#39;) and the integral value (i&#39;-1, j&#39;) according to a control signal delivered from a control unit 911. The weighting coefficient W&#39; A  (i&#39;) is supplied to a coefficient multiplying unit 903. The coefficient multiplying unit 903 multiplies the input coefficient by either coefficient of &#34;1&#34; or &#34;1/2&#34; according to the control of the controller 911, and outputs the result thus obtained. At this point in time, it is multiplied by &#34;1/2&#34;. A multiplying unit 904 multiplies the distance read out from the memory 104 under the control of the read controller 901 by the output delivered from the coefficient multiplying unit 903. An adder 906 adds the weighted distance delivered from the unit 904 and a previous integral value read out from the memory 106 under the control of the read controller 905, and the result is stored in a register 907. Consequently, the calculated result stored in the register 907 corresponds to the upper part of the recurrence formula (17-3). Next, the control unit 911 controls the read controller 901, 902 and 905 so as to read-out of the distance d&#39;(i&#39;,j&#39;), the weighting coefficient W B  &#39;(j&#39;-1) and the integral value g(i&#39;, j&#39;-2), respectively. The coefficient multiplying unit 903, the multiplying unit 904 and the adder 906 operate in the same manner discribed above, and a calculation result corresponding to the lower part of the recurrent formula (17-3) is stored into the register 907. 
     In this case, the content corresponding to the upper part of the formula (17-3) in the register 907 is previously shifted to a register 908, and the coefficient &#34;1&#34; is used at the coefficient multiplying unit 903. A minimum value decision unit 909 compares values stored in two registers 907 and 908 and outputs the smaller value. The smaller value is then stored in the integral memory 106 as the integral value g&#39;(i&#39;,j&#39;). Calculations of the recurrence formulas (17-2) and (17-1) are carried out in accordance with control signals (i&#39;,j&#39;)(=(2i-1, 2j-2)) and (i&#39;,j&#39;)(=(2i=1, 2j-1)), respectively, in the same manner described above. 
     A control unit 107 controls the distance calculating unit 300, the control signal converter 108 and the recurrence formula calculating unit 900 in accordance with the control signals i and j which are sequentially shifted from i=1 and j=1 to i=I and j=J, and a block 910 finally derives the distance between two patterns defined by the equation (18) by using the integral value g(I&#39;,J&#39;) (=g (2I-1, 2J-1)) which is obtained at the point of i=I and j=J. 
     The present invention has been described above and it is possible to apply another recurrence formula instead of the recurrence formulas employed in the description. Further, an arbitrary method is available for compressing patterns in the piecewise line approximation. The voice pattern has been taken up for example in the description, however, the invention can be applied to any arbitrary pattern of letter character, etc. subject to being expressed as a series of feature vectors.