Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
111 views
in Technique[技术] by (71.8m points)

java - Finding the mathematical algorithm to which matches an input and output together

As an end result, I would like a computer program which can accept a list of inputs and outputs and then apply the same algorithm that went into those input/output's on another number, I.e:

If given this list of input/output's

2:4
4:8
100:200

It would realize that the algorithm would be (input * 2), or (output / 2) depending on what we wanted.

So, if given the number 16, and asked to produce an output the program would respond with 32. And if given the number 10 and asked to produce an input, it would respond with 5.

It would obviously be rather simple to 'hardcode' this into the program, although I'd like to learn how to have the program teach itself what the algorithm is. I understand that this will get rather complicated rather fast.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

you can not do this reliably for any type of input/output signal dependency instead you should support only some otherwise you need some kind of AI or very complex neural network + many functional generators with insane complexity and unknown reliability of the solution ...

I would simplify this to dependencies like:

  1. polynomial up to some degree

    • (can use any interpolation/approximation)
    • y=a0+a1*x+a2*x*x+a3*x*x*x
  2. exponential

    • y=a0+a1^x
  3. other

    • If you want to support things like sin waves etc then you would need many inputs not just few to decide the type of dependency.

Anyway I think just 3 input points will be not enough

  • for example polynomial a0+a1*x+a2*x*x+a3*x*x*x=y needs at least 4 points

So at first you should determine which type of dependency it is and then try to find the coefficients of that particular function generator. For example:

  • if you have inputs x0<x1<x2<x3,... and outputs y0,y1,y2,y3,..
  • and k0=y0/x0,k1=y1/x1,...
  • if k0<<k1<<k2<<k3<<... or k0>>k1>>k2>>k3>>... it is probably exponential dependency
  • otherwise use polynomial ...

If you have mixed type signals then you need much more input points covering big enough range and probably would need some kind of approximation search of coefficients minimizing the distance between known inputs and generated output. If you have enough points you can normalize dataset and use correlation coefficient to compare it with supported function generators to simplify the decisioning

[Notes]

So you need to specify:

  • what kind of dependencies will be supported (types,singular,combined)
  • how many input points you have (minimum, recommended etc...)
  • what is the target precision/error
  • what is the target ranges of x,y

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...