GithubHelp home page GithubHelp logo

curvefitting's Introduction

Polynomial Curve Fitting

Basic Principle: In mathematics, a Taylor series is a representation of a function as an infinite sum of terms that are calculated from the values of the function’s derivatives at a single point, which means a function can be approximated by using a finite number of terms of its Taylor series.

The goal of this project is to use genetic algorithm to find a set of coefficients for a polynomial function which fits a series of given data well.

Getting Started

The following variables can be initialized when constructing a GA object.

  • original data path
  • population size
  • polynomial degree
  • maximum generation
  • survival rate
  • crossover rate
  • mutation rate

example: GA ga = new GA("Data.txt", 2000, 7, 1000, 0.5, 0.8, 0.1);

Implementation Details

Genetics

  • Genotype: A double array of coefficients. The index of coefficient is equivalent to each term's degree.
  • Phenotype: A polynomial fitting function. This also describes how the genes are expressed.

example: f(x)=a+bx+cx^2+dx^3+ex^4

Mutation

  • Option 1: change coefficient value
  • Option 2: swap two coefficients

Crossover

For each gene/coefficient, a child inherits father’s or mother’s with equal possibility.

Fitness/Difference

Using the method of least squares, the difference between the calculated value and the actual value on the Y axis is compared and added point by point. Therefore, the larger the differences, the higher the value of fitness would be. In each population, which is implemented by a priority queue, the top one is the best with the smallest fitness value.

Selection

During each generation, the fittest one will be directly copied into the next generation. And the next generation’s population size will continue increasing either by crossing over two randomly selected survivors’ genes or mutating a survivor’s genes until it reaches the predefined scale.

Observations & Analyses

See Polynomial Curve Fitting.pptx

curvefitting's People

Contributors

bumblefeng avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.