Newlisp Data Fitting

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.