Sometimes we need to fit the data. For example, if the data on a Friday cannot be generated for some reason, we can use the following algorithm for simple fitting.
Calculate the week-on-week ratio of the first two weeks and the week-on-week ratio. Calculate the two adjacent ratios by adding 1 after the average value and multiply the data of the week to obtain the data of the week.
Using newlisp to implement code is simple:
See the following example:
#! /Usr/bin/newlisp (define (adjacent-Div a B) (Div (sub B a) (define (average a B) (Div (add a B) (2) (define (fitting a B c d e) (INT (MUL (add (average (adjacent-Div a B) (adjacent-Div C D) 1) e) (println (fitting 736500 743138 733101 720626) (println (fitting 762747 743138 801841 720626) (println (fitting 756950 759694 801841 914530) (Exit)
The final result is:
~ $./B. lsp759694808846939133
Newlisp Data Fitting