Streaming Newton interpolation method based on fixed-width window
By adopting a streaming Newtonian interpolation method based on a fixed-width window in data processing, the problem that noise data processing is difficult to maintain smoothness and original characteristics in the prior art is solved, and effective repair of noise data and rapid generation of data curves are achieved.
Patent Information
- Application Number
- CN202411781531.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-03-28
AI Technical Summary
When processing distance data containing noisy data, it is difficult to maintain the smoothness and original characteristics of the data, especially in scenarios where data transformation is more flexible.
The streaming Newtonian interpolation method based on a fixed-width window is used to read data points from the ring array, and a polynomial is constructed by calculating the mean difference value, and unknown data points are inferred, which is suitable for rapid generation of curves for high-performance and trend analysis of data.
It realizes effective identification and repair of noise data, maintains data smoothness and original characteristics, and is suitable for scenarios where curves need to be generated quickly from finite data points.
Smart Images

Figure CN119719601A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a fixed-width window streaming Newton interpolation method. Background Art
[0002] In a two-dimensional plane, as time goes by, the positioning subject continuously generates one-dimensional distance data. These data may contain noise data that does not match the actual distance. These data need to be identified and repaired so that they can accurately reflect their actual distance values and make the distance changes smooth enough to match the actual situation.
[0003] Most of the fitting methods to solve this scenario use one-dimensional linear fitting, which has the advantages of small amount of calculation and simple implementation logic. However, its disadvantages are also very obvious. In scenarios where data transformation is more flexible, some floating characteristics of the original data will be lost, and it cannot meet the requirements of scenarios where data performance requires a more restored original state. Summary of the invention
[0004] The present invention provides a fixed-width window streaming Newton interpolation method. As a numerical calculation method, a polynomial function is constructed through known data points to infer unknown data points. It is suitable for occasions where it is necessary to quickly generate curves from limited data points for data high efficiency and trend analysis.
[0005] The present invention provides a fixed-width window streaming Newton interpolation method, comprising:
[0006] Read n sets of data from the ring array ringbuffer, each set of data has a horizontal coordinate value x and a corresponding vertical coordinate value y;
[0007] According to n groups of data, a preset stream Newton interpolation method is used to calculate and obtain n-1 mean difference values; wherein the n-1 mean difference values are a first-order mean difference value, a second-order mean difference value, ..., an n-1-order mean difference value;
[0008] Constructing a polynomial according to n-1 mean difference values; wherein the polynomial includes abscissa, ordinate, order, first-order mean difference value, second-order mean difference value, ..., n-1-order mean difference value;
[0009] Obtain a new horizontal coordinate value x, and substitute the new horizontal coordinate value x into the polynomial to obtain a new vertical coordinate value y corresponding to the new horizontal coordinate value x;
[0010] The new horizontal coordinate value x and the corresponding new vertical coordinate value y are written into the ring array ringbuffer.
[0011] Furthermore, the ring array ringbuffer includes a read pointer read, a write pointer start, and a count counter, which stores the number of elements actually readable in the current buffer;
[0012] When writing data into the ring array ringbuffer, the write pointer start points to the address pointed to by the current read pointer read; during the entire data writing process, the address pointed to by the subsequent write pointer start is calculated as follows:
[0013] start=(start+1)%ringbuffer.length.
[0014] Furthermore, in the step of calculating according to n sets of data using a preset streaming Newton interpolation method to obtain n-1 mean difference values, in the preset streaming Newton interpolation method, the derivation process of the Newton interpolation polynomial is:
[0015] When there is only one pair of data points x 0 ,y 0 When , the interpolation polynomial is:
[0016] f 0 (x) = y 0
[0017] Remember a 0 =y 0 ;
[0018] Add data point x 1 ,y 1 , the image of the interpolation function is through the point (x 0 ,y 0 ),(x 1 ,y 1 ) straight line, the equation of the interpolation function is:
[0019]
[0020] remember
[0021] Add data point x 2 ,y 2 , the equation of the interpolation function is:
[0022]
[0023] Using f 2 (x 2 )=y 2 We can solve a 2 , then f 2 (x) is:
[0024]
[0025] Each time a data point is added, only one modification needs to be made to the original interpolation polynomial, that is, one term is added;
[0026] For a given n pairs of data points, there exists a pair that satisfies f(x i )=y i A polynomial function f(x) of degree not more than n-1 can be written as follows:
[0027] f(x)=a 0 +a 1 (x-x 0 )+a 2 (x-x 0 )(χ-x 1 )+…+a n (xx 0 )(χ-x 1 )…(χ-x n-1 )
[0028] where a i That is the mean difference.
[0029] Furthermore, according to the derivation process of Newton interpolation polynomial, the second-order mean difference calculation formula is obtained as follows:
[0030]
[0031] The formula for calculating the higher-order mean difference is derived as follows:
[0032]
[0033] Among them, f[x i ,x j ] is the second-order mean difference, f[x 0 ,x 1 ,…,x k ] is the higher-order mean difference.
[0034] Furthermore, according to the derivation process of Newton interpolation polynomial and the mean difference calculation formula, the stream interpolation method is preset and the rolling mean difference calculation is adopted, that is, each time there is a new set of data x i ,f(x i ) is generated, reuse the previously obtained f(x i-4 ),f[x i-4 ,x i-3 ],f[x i-4 ,x i-3 ,x i-2 ],f[x i-4 ,x i-3 ,x i-2 ,xi-1 ] calculate f[x i-4 ,x i-3 ,x i-2 ,x i-1 ,x i ], as in the reciprocating, based on the custom fractional structure, the ring array ringbuffer always generates a constant order mean difference a on a fixed width i-4 ,a i-3 ,a i-2 ,a i-1 ,a i .
[0035] The present invention also provides a fixed-width window streaming Newton interpolation device, comprising:
[0036] The reading module is used to read n groups of data from the ring array ringbuffer, each group of data has a horizontal coordinate value x and a corresponding vertical coordinate value y;
[0037] A calculation module, used for calculating according to n groups of data by using a preset stream Newton interpolation method to obtain n-1 mean difference values; wherein the n-1 mean difference values are a first-order mean difference value, a second-order mean difference value, ..., an n-1-order mean difference value;
[0038] A construction module, used to construct a polynomial according to n-1 mean difference values; wherein the polynomial includes a horizontal coordinate, a vertical coordinate, a class, a first-order mean difference value, a second-order mean difference value, ..., an n-1-order mean difference value;
[0039] A substitution module is used to obtain a new horizontal coordinate value x, and substitute the new horizontal coordinate value x into the polynomial to obtain a new vertical coordinate value y corresponding to the new horizontal coordinate value x;
[0040] The writing module is used to write the new horizontal coordinate value x and the corresponding new vertical coordinate value y into the ring array ringbuffer.
[0041] The present invention also provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.
[0042] The present invention also provides a computer-readable storage medium on which a computer program is stored, and the computer program implements the steps of the above method when executed by a processor.
[0043] The beneficial effects of the present invention are:
[0044] The present invention reads n groups of data from a ring array ringbuffer, each group of data having a horizontal coordinate value x and a corresponding vertical coordinate value y; calculates according to the n groups of data using a preset stream Newton interpolation method to obtain n-1 mean difference values; constructs a polynomial according to the n-1 mean difference values; obtains a new horizontal coordinate value x, and substitutes the new horizontal coordinate value x into the polynomial to obtain a new vertical coordinate value y corresponding to the new horizontal coordinate value x, and writes it into the ring array ringbuffer. A polynomial function is constructed through known data points to infer unknown data points, which is suitable for occasions where a curve needs to be quickly generated from limited data points for data high efficiency and trend analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 The figure is a schematic diagram of a method flow according to an embodiment of the present invention.
[0046] Figure 2 This is an initial schematic diagram of the annular array in the present invention.
[0047] Figure 3 This is a schematic diagram of a circular array after writing a data in the present invention.
[0048] Figure 4 This is a schematic diagram of the last remaining space of the circular array in the present invention.
[0049] Figure 5 This is a schematic diagram of writing new data into a circular array to overwrite old data in the present invention.
[0050] Figure 6 This is a schematic diagram of continuing to write new data in the present invention.
[0051] Figure 7 FIG. 1 is a schematic diagram of a device structure according to an embodiment of the present invention.
[0052] Figure 8 The figure is a schematic diagram of the internal structure of a computer device according to an embodiment of the present invention.
[0053] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0054] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0055] In the spatiotemporal context of personnel movement, time t is the horizontal coordinate and spatial position is the vertical coordinate. Then these data will form a series of time-series and streaming data with internal connections. These data will occasionally be distorted during the acquisition process of the positioning device, or when the internal rules of the data are very standard, the data will be scientifically filled in for the sake of data smoothness and immediacy. At this time, the application of streaming interpolation will effectively solve these two problems.
[0056] In order to ensure the accuracy of the data, a high-precision and large-capacity fraction structure needs to be implemented first. Most programming languages do not directly provide fraction structures, only integers and floating-point numbers. Among them, floating-point numbers basically follow the IEEE-754 standard. Floating-point numbers expressed in this way are inherently prone to certain errors. Calculations between numbers with errors will further increase the errors, and ultimately lead to a significant reduction in the accuracy of the calculation results.
[0057] In order to solve this problem, the present invention designs a fraction structure. The denominator and numerator are respectively 64-bit integer data of long type, and the fraction structure is expanded with related addition, subtraction, multiplication, division, decimal to fraction, and fraction to decimal. The result obtained after any addition, subtraction, multiplication, and division of fractions is still a fraction. Such a design ensures 100% accuracy of the calculation result.
[0058] like Figure 1 As shown, the present invention provides a fixed-width window streaming Newton interpolation method, comprising:
[0059] S1, read n groups of data from the ring array ringbuffer, each group of data has a horizontal coordinate value x and a corresponding vertical coordinate value y;
[0060] S2. Calculate according to n groups of data using a preset stream Newton interpolation method to obtain n-1 mean difference values; wherein the n-1 mean difference values are a first-order mean difference value, a second-order mean difference value, ..., an n-1-order mean difference value;
[0061] S3. Construct a polynomial according to n-1 mean difference values; wherein the polynomial includes abscissa, ordinate, order, first-order mean difference value, second-order mean difference value, ..., n-1-order mean difference value;
[0062] S4, obtaining a new horizontal coordinate value x, and substituting the new horizontal coordinate value x into the polynomial to obtain a new vertical coordinate value y corresponding to the new horizontal coordinate value x;
[0063] S5. Write the new horizontal coordinate value x and its corresponding new vertical coordinate value y into the ring array ringbuffer.
[0064] In one embodiment, in order to process unlimited data in limited memory, a ring array ringbuffer needs to be constructed. For example, the array element size is 5, including two pointers: read pointer read and write pointer start, and a count counter, which stores the actual number of readable elements in the current buffer. The initial schematic is as follows: Figure 2 shown.
[0065] After writing a data to the address pointed to by the start pointer, the read pointer remains unchanged, and the start pointer moves backward to point to the subsequent address to be written, such as Figure 3 shown.
[0066] Continue writing data to the ringbuffer until there is only one space left. Figure 4 shown.
[0067] When continuing to write data to the ringbuffer, start points to the address currently pointed to by read. During the entire data writing process, the subsequent start address is calculated as start = (start + 1) % ringbuffer.length; according to this guide, when continuing to write data to the ringbuffer, the status will become as follows Figure 5 The form shown.
[0068] That is, read always points to the oldest data, so that when reading data from the ringbuffer, it can be read from the ringbuffer in the order of first-in-first-out. So, when continuing to write data into it, it will be like this Figure 6 The form shown.
[0069] As the order of fitting increases, the fitting error will increase. The streaming interpolation method can solve this problem and control the order at a fixed level. For a ringbuffer with a sliding window length of 5, the maximum mean error of the streaming interpolation method can be controlled to 4th order.
[0070] In one embodiment, the derivation process of Newton interpolation polynomial is:
[0071] When there is only one pair of data points x 0 ,y 0 When , the interpolation polynomial is:
[0072] f 0 (x) = y 0 (1)
[0073] Remember a 0 =y 0 ;
[0074] Add data point x1 ,y 1 , the image of the interpolation function is through the point (x 0 ,y 0 ),(x 1 ,y 1 ) straight line, the equation of the interpolation function is:
[0075]
[0076] remember
[0077] Add data point x 2 ,y 2 , in order to write a formula similar to (2), assume that:
[0078]
[0079] Using f 2 (x 2 )=y 2 We can solve a 2 , then f 2 (x) is:
[0080]
[0081] Each time a data point is added, only one correction needs to be made to the original interpolation polynomial, that is, one term is added. This is the derivation process of Newton's interpolation polynomial.
[0082] For a given n pairs of data points, there exists a pair that satisfies f(x i )=y i A polynomial function f(x) of degree not more than n-1 can be written as follows:
[0083] f(x)=a 0 +a 1 (Xx 0 )+a 2 (x-x 0 )(χ-x 1 )+…+a n (xx 0 )(χ-x 1 )…(χ-x n-1 )
[0084] where a i That is the mean difference.
[0085] As the number of known points gradually increases, the order of the mean difference will gradually increase, and as the order increases, the accuracy of the fitting will gradually decrease.
[0086] The variance calculation gradient table for each division is as follows:
[0087] <![CDATA[x k ]]> <![CDATA[f(x k )]]> First-order mean difference Second-order mean difference Third-order mean difference Fourth-order mean difference <![CDATA[x 0 ]]> <![CDATA[f(x 0 )]]> <![CDATA[x 1 ]]> <![CDATA[f(x 1 )]]> <![CDATA[f[x 0 ,x 1 ]]]> <![CDATA[x 2 ]]> <![CDATA[f(x 2 )]]> <![CDATA[f[x 1 ,x 2 ]]]> <![CDATA[f[x 0 ,x 1 ,x 2 ]]]> <![CDATA[x 3 ]]> <![CDATA[f(x 3 )]]> <![CDATA[f[x 2 ,x 3 ]]]> <![CDATA[f[x 1 ,x 2 ,x 3 ]]]> <![CDATA[f[x 0 ,x 1 ,x 2 ,x 3 ]]]> <![CDATA[x 4 ]]> <![CDATA[f(x 4 )]]> <![CDATA[f[x 3 ,x 4 ]]]> <![CDATA[f[x 2 ,x 3 ,x 4 ]]]> <![CDATA[f[x 1 ,x 2 ,x 3 ,x 4 ]]]> <![CDATA[f[x 0 ,x 1 ,x 2 ,x 3 ,x 4 ]]]>
[0088] Among them, the elements on the diagonal (f(x 0 ),f[x 0 , x 1 ]、f[x 0 , x 1 , x 2 ]、f[x 0 , x 1 , x 2 , x 3 ]、f[x 0 , x 1 , x 2 , x 3 , x 4 ]) From the upper left to the lower right is a 0 , a 1 , a 2 , a 3 , a 4 .
[0089] The formula for calculating the second-order mean difference is:
[0090]
[0091] example:
[0092]
[0093] The formula for calculating the higher-order mean difference is derived as follows:
[0094]
[0095] example:
[0096]
[0097] Among them, f[x i , x j ] is the second-order mean difference, f[x 0 , x 1 , …, x k ] is the higher-order mean difference.
[0098] This paper introduces the derivation of Newton's interpolation formula and the calculation method of mean difference.
[0099] The streaming interpolation method uses the following method to calculate the rolling mean difference, which can fix the mean difference at the fourth order to avoid excessive errors.
[0100] First round of calculations:
[0101] <![CDATA[x k ]]> <![CDATA[f(x k )]]> First-order mean difference Second-order mean difference Third-order mean difference Fourth-order mean difference <![CDATA[x 0 ]]> <![CDATA[f(x 0 )]]> <![CDATA[x 1 ]]> <![CDATA[f(x 1 )]]> <![CDATA[f[x 0 ,x 1 ]]]> <![CDATA[x 2 ]]> <![CDATA[f(x 2 )]]> <![CDATA[f[x 1 ,x 2 ]]]> <![CDATA[f[x 0 ,x 1 ,x 2 ]]]> <![CDATA[x 3 ]]> <![CDATA[f(x 3 )]]> <![CDATA[f[x 2 ,x 3 ]]]> <![CDATA[f[x 1 ,x 2 ,x 3 ]]]> <![CDATA[f[x 0 ,x 1 ,x 2 ,x 3 ]]]> <![CDATA[x 4 ]]> <![CDATA[f(x 4 )]]> <![CDATA[f[x 3 ,x 4 ]]]> <![CDATA[f[x 2 ,x 3 ,x 4 ]]]> <![CDATA[f[x 1 ,x 2 ,x 3 ,x 4 ]]]> <![CDATA[f[x 0 ,x 1 ,x 2 ,x 3 ,x 4 ]]]>
[0102] Second round of calculation:
[0103] <![CDATA[x k ]]> <![CDATA[f(x k )]]> First-order mean difference Second-order mean difference Third-order mean difference Fourth-order mean difference <![CDATA[x 1 ]]> <![CDATA[f(x 1 )]]> <![CDATA[x 2 ]]> <![CDATA[f(x 2 )]]> <![CDATA[f[x 1 ,x 2 ]]]> <![CDATA[x 3 ]]> <![CDATA[f(x 3 )]]> <![CDATA[f[x 2 ,x 3 ]]]> <![CDATA[f[x 1 ,x 2 ,x 3 ]]]> <![CDATA[x 4 ]]> <![CDATA[f(x 4 )]]> <![CDATA[f[x 3 ,x 4 ]]]> <![CDATA[f[x 2 ,x 3 ,x 4 ]]]> <![CDATA[f[x 1 ,x 2 ,x 3 ,x 4 ]]]> <![CDATA[x 5 ]]> <![CDATA[f(x 5 )]]> <![CDATA[f[x 4 ,x 5 ]]]> <![CDATA[f[x 3 ,x 4 ,x 5 ]]]> <![CDATA[f[x 2 ,x 3 ,x 4 ,x 5 ]]]> <![CDATA[f[x 1 ,x 2 ,x 3 ,x 4 ,x 5 ]]]>
[0104] The third round of calculations:
[0105] <![CDATA[x k ]]> <![CDATA[f(x k )]]> First-order mean difference Second-order mean difference Third-order mean difference Fourth-order mean difference <![CDATA[x 2 ]]> <![CDATA[f(x 2 )]]> <![CDATA[x 3 ]]> <![CDATA[f(x 3 )]]> <![CDATA[f[x 2 ,x 3 ]]]> <![CDATA[x 4 ]]> <![CDATA[f(x 4 )]]> <![CDATA[f[x 3 ,x 4 ]]]> <![CDATA[f[x 2 ,x 3 ,x 4 ]]]> <![CDATA[x 5 ]]> <![CDATA[f(x 5 )]]> <![CDATA[f[x 4 ,x 5 ]]]> <![CDATA[f[x 3 ,x 4 ,x 5 ]]]> <![CDATA[f[x 2 ,x 3 ,x 4 ,x 5 ]]]> <![CDATA[x 6 ]]> <![CDATA[f(x 6 )]]> <![CDATA[f[x 5 ,x 6 ]]]> <![CDATA[f[x 4 ,x 5 ,x 6 ]]]> <![CDATA[f[x 3 ,x 4 ,x 5 ,x 6 ]]]> <![CDATA[f[x 2 ,x 3 ,x 4 ,x 5 ,x 6 ]]]>
[0106] As shown above, each time there is a new set of data x i ,f(x i ) is generated, reuse the previously obtained f(x i-4 ), f[x i-4 , x i-3 ],f[x i-4 , x i-3 , x i-2 ],f[x i-4 , x i-3 , x i-2 , x i-1 ] calculate f[x i-4 , x i-3 , x i-2 , x i-1 , x i ], as in the reciprocating, based on the custom fractional structure, the ring array ringbuffer always generates a constant order mean difference a on a fixed width i-4 , a i-3 , a i-2 , a i-1 , a i .
[0107] The above method controls the mean difference to be fixed at the fourth order so as not to generate excessive errors, which is for any set of data. However, in the calculation process, this "any set of data" is gradually filled with time, and the present invention takes the latest 5 sets of data of the continuously filled data to obtain the mean difference below the fourth order. The operation mechanism of "intercepting the data like flowing water generated over time with a fixed width" is called sliding window data acquisition.
[0108] Specific examples:
[0109] The following set of data is generated in sequence
[0110] x 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 y 25 22 21 19 16 14 12 10 6 7 9 12 14 17 18
[0111] The polynomial that can be calculated from the first five sets of data (9-13) is:
[0112]
[0113] Among them, using its fitting 14, the value of y is 15, and the error is
[0114] After generating a new set of data (15, 12), two formulas are obtained:
[0115] Traditional Newton interpolation f(15)=16
[0116] Stream interpolation method of the present invention f(15)=17
[0117] According to this rule, we will get the following table:
[0118] Fitting data Traditional fitting Stream Fitting Traditional Error Flow Error 14 15 15 1 / 14 1 / 14 15 16 17 4 / 12 5 / 12 16 -3 6 13 / 10 4 / 10 17 35 9 29 / 6 3 / 6 18 -59 -4 66 / 7 11 / 7 19 178 29 171 / 7 22 / 7 20 -437 -3 449 / 12 15 / 12 21 1153 20 1139 / 14 6 / 14
[0119] From the comparison in the above table, it can be seen that the accuracy of the streaming interpolation method is significantly higher than that of the Newton interpolation fitting without any processing.
[0120] The present invention reads n groups of data from a ring array ringbuffer, each group of data having a horizontal coordinate value x and a corresponding vertical coordinate value y; calculates according to the n groups of data using a preset stream Newton interpolation method to obtain n-1 mean difference values; constructs a polynomial according to the n-1 mean difference values; obtains a new horizontal coordinate value x, and substitutes the new horizontal coordinate value x into the polynomial to obtain a new vertical coordinate value y corresponding to the new horizontal coordinate value x, and writes it into the ring array ringbuffer. A polynomial function is constructed through known data points to infer unknown data points, which is suitable for occasions where a curve needs to be quickly generated from limited data points for data high efficiency and trend analysis.
[0121] like Figure 7 As shown, the present invention also provides a fixed-width window streaming Newton interpolation device, comprising:
[0122] The reading module 1 is used to read n groups of data from the ring array ringbuffer, each group of data has a horizontal coordinate value x and a corresponding vertical coordinate value y;
[0123] A calculation module 2 is used to calculate according to n groups of data using a preset stream Newton interpolation method to obtain n-1 mean difference values; wherein the n-1 mean difference values are a first-order mean difference value, a second-order mean difference value, ..., an n-1-order mean difference value;
[0124] Construction module 3, used to construct a polynomial according to n-1 mean difference values; wherein the polynomial includes abscissa, ordinate, order, first-order mean difference value, second-order mean difference value, ..., n-1-order mean difference value;
[0125] Substitution module 4 is used to obtain a new horizontal coordinate value x, and substitute the new horizontal coordinate value x into the polynomial to obtain a new vertical coordinate value y corresponding to the new horizontal coordinate value x;
[0126] The writing module 5 is used to write the new horizontal coordinate value x and the corresponding new vertical coordinate value y into the ring array ringbuffer.
[0127] In one embodiment, in the reading module 1 and the writing module 5, the ring array ringbuffer includes a read pointer read, a write pointer start, and a count counter, which stores the number of elements actually readable in the current buffer;
[0128] When writing data into the ring array ringbuffer, the write pointer start points to the address pointed to by the current read pointer read; during the entire data writing process, the address pointed to by the subsequent write pointer start is calculated as follows:
[0129] start=(start+1)%ringbuffer.length.
[0130] In one embodiment, in the calculation module 2, in the preset stream Newton interpolation method, the derivation process of the Newton interpolation polynomial is:
[0131] When there is only one pair of data points x 0 ,y 0 When , the interpolation polynomial is:
[0132] f 0 (x) = y 0
[0133] Remember a 0 =y 0 ;
[0134] Add data point x 1 ,y 1 , the image of the interpolation function is through the point (x 0 ,y 0 ),(x 1 ,y 1 ) straight line, the equation of the interpolation function is:
[0135]
[0136] remember
[0137] Add data point x 2 ,y 2 , the equation of the interpolation function is:
[0138]
[0139] Using f 2 (x 2 )=y 2 We can solve a 2 , then f 2 (x) is:
[0140]
[0141] Each time a data point is added, only one modification needs to be made to the original interpolation polynomial, that is, one term is added;
[0142] For a given n pairs of data points, there exists a pair that satisfies f(x i )=y i A polynomial function f(x) of degree not more than n-1 can be written as follows:
[0143] f(x)=a 0 +a 1 (x-x 0 )+a 2 (x-x 0 )(χ-x 1 )+…+a n (xx 0 )(χ-x 1 )…(χ-x n-1 )
[0144] where a i That is the mean difference.
[0145] In one embodiment, in the calculation module 2, according to the derivation process of the Newton interpolation polynomial, the second-order mean difference calculation formula is obtained as follows:
[0146]
[0147] The formula for calculating the higher-order mean difference is derived as follows:
[0148]
[0149] Among them, f[x i ,x j ] is the second-order mean difference, f[x 0 ,x 1 ,…,x k ] is the higher-order mean difference.
[0150] In one embodiment, in the calculation module 2, according to the derivation process of Newton interpolation polynomial and the mean difference calculation formula, a stream interpolation method is preset, and a rolling mean difference calculation is adopted, that is, each time there is a new set of data x i ,f(x i) is generated, reuse the previously obtained f(x i-4 ),f[x i-4 ,x i-3 ],f[x i-4 ,x i-3 ,x i-2 ],f[x i-4 ,x i-3 ,x i-2 ,x i-1 ]Calculate
[0151] f[x i-4 ,x i-3 ,x i-2 ,x i-1 ,x i ], as in the reciprocating, based on the custom fractional structure, the ring array ringbuffer always generates a constant order mean difference a on a fixed width i-4 ,a i-3 ,a i-2 ,a i-1 ,a i .
[0152] The above modules are used to execute the corresponding steps in the above fixed-width window streaming Newton interpolation method. The specific implementation method thereof is described in the above method embodiment and will not be repeated here.
[0153] like Figure 8 As shown, the present invention also provides a computer device, which can be a server, and its internal structure can be as shown in Figure 8 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor designed by the computer is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store all data required for the process based on the fixed-width window streaming Newton interpolation method. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the fixed-width window streaming Newton interpolation method is implemented.
[0154] Those skilled in the art will understand that Figure 8 The structure shown in is merely a block diagram of a portion of the structure related to the present application solution and does not constitute a limitation on the computer device to which the present application solution is applied.
[0155] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, any one of the above-mentioned fixed-width window streaming Newton interpolation methods is implemented.
[0156] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing related hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media provided in this application and used in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0157] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the presence of other identical elements in the process, device, article or method including the element.
[0158] The above description is only a preferred embodiment of the present invention, and does not limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A Newton interpolation method based on a fixed-width window stream, characterized in that: include: Read n sets of data from the ring array ringbuffer, each set of data has a horizontal coordinate value x and a corresponding vertical coordinate value y; According to n groups of data, a preset stream Newton interpolation method is used to calculate and obtain n-1 mean difference values; wherein the n-1 mean difference values are a first-order mean difference value, a second-order mean difference value, ..., an n-1-order mean difference value; Constructing a polynomial according to n-1 mean difference values; wherein the polynomial includes abscissa, ordinate, order, first-order mean difference value, second-order mean difference value, ..., n-1-order mean difference value; Obtain a new horizontal coordinate value x, and substitute the new horizontal coordinate value x into the polynomial to obtain a new vertical coordinate value y corresponding to the new horizontal coordinate value x; The new horizontal coordinate value x and the corresponding new vertical coordinate value y are written into the ring array ringbuffer.
2. The fixed-width window streaming Newton interpolation method according to claim 1 is characterized in that: The ring array ringbuffer includes a read pointer read, a write pointer start, and a count counter, which stores the number of elements actually readable in the current buffer; When writing data into the ring array ringbuffer, the write pointer start points to the address pointed to by the current read pointer read; during the entire data writing process, the address pointed to by the subsequent write pointer start is calculated as start=(start+1)%ringbuffer.length.
3. The fixed-width window streaming Newton interpolation method according to claim 1 is characterized in that: In the step of calculating according to n groups of data using a preset stream Newton interpolation method to obtain n-1 mean difference values, in the preset stream Newton interpolation method, the derivation process of the Newton interpolation polynomial is: When there is only one pair of data points x0, y0, the interpolation polynomial is: f0(x)=y0 Let a0 = y0; Add data points x1, y1, the image of the interpolation function is a straight line passing through the points (x0, y0) and (x1, y1), and the equation of the interpolation function is: remember Add data points x2, y2, and get the equation of the interpolation function: Using f2(x2)=y2, we can solve for a2, so f2(x) is: Each time a data point is added, only one modification needs to be made to the original interpolation polynomial, that is, one term is added; For a given n pairs of data points, there exists a pair that satisfies f(x i )=y i A polynomial function f(x) of degree not more than n-1 can be written as follows: f(x)=a0+a1(χ-x0)+a2(χ-x0)(χ-x1)+…+a n (x-x0)(x-x1)…(x-x n-1 ) where a i That is the mean difference.
4. The fixed-width window streaming Newton interpolation method according to claim 3 is characterized in that: According to the derivation process of Newton interpolation polynomial, the second-order mean difference calculation formula is obtained as follows: The formula for calculating the higher-order mean difference is derived as follows: Among them, f[x i ,x j ] is the second-order mean difference, f[x0,x1,…,x k ] is the higher-order mean difference.
5. The method of Newton interpolation based on fixed-width window streaming according to claim 4 is characterized in that: According to the derivation process of Newton interpolation polynomial and the mean difference calculation formula, the stream interpolation method is preset and the rolling mean difference calculation is adopted, that is, each time there is a new set of data x i ,f(x i ) is generated, reuse the previously obtained f(x i-4 ),f[x i-4 ,x i-3 ],f[x i-4 ,x i-3 ,x i-2 ],f[x i-4 ,x i-3 ,x i-2 ,x i-1 ] calculate f[x i-4 ,x i-3 ,x i-2 ,x i-1 ,x i ], as in the reciprocating, based on the custom fractional structure, the ring array ringbuffer always generates a constant order mean difference a on a fixed width i-4 ,a i-3 ,a i-2 ,a i-1 ,a i .
6. A Newton interpolation device based on fixed-width window streaming, characterized in that: include: The reading module is used to read n groups of data from the ring array ringbuffer, each group of data has a horizontal coordinate value x and a corresponding vertical coordinate value y; A calculation module, used for calculating according to n groups of data by using a preset stream Newton interpolation method to obtain n-1 mean difference values; wherein the n-1 mean difference values are a first-order mean difference value, a second-order mean difference value, ..., an n-1-order mean difference value; A construction module, used to construct a polynomial according to n-1 mean difference values; wherein the polynomial includes a horizontal coordinate, a vertical coordinate, a class, a first-order mean difference value, a second-order mean difference value, ..., an n-1-order mean difference value; A substitution module is used to obtain a new horizontal coordinate value x, and substitute the new horizontal coordinate value x into the polynomial to obtain a new vertical coordinate value y corresponding to the new horizontal coordinate value x; The writing module is used to write the new horizontal coordinate value x and the corresponding new vertical coordinate value y into the ring array ringbuffer.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.