开发者

Approximate function with genetic algorithm

Are there modules in python to approximate a given function(a) with a genetic algorithm to receive a function(b) which produces the same or similar outputs with the same inputs? Why approximate? The workings of function(a) are not known. So basically what the algorithm should do is minimizing the deviation from sample values produced by function(a) and mutating function(b). Any ideas?

Example:

1.Iteration:
f(a):  0 -> 5, 1 -> 3, 2 -> 7
f(bi): 0 -> 4, 1 -> 6, 2 -> 3
devi:       1       3       4
sum(devi):  8
...
f(bn): 0 开发者_C百科-> 3, 1 -> 2, 2 -> 1
devn:       2       1       4
sum(devn):  7   ------------> 'fitter function - use for mutation'

mutate f(b):

2.Iteration:
f(a):  0 -> 5, 1 -> 3, 2 -> 7, ...
f(bi): 0 -> 5, 1 -> 6, 2 -> 3, ...
devi:       0       3       4
...


What you're lookin for is called Extrapolation .

The are alot of algorithms that do that, and they're just mathematical so they can be easily implemented.

If you want to create a function that will simulate the first one with in the same range of input, you can use Interpolation which is kinda the same, but with better accuracy because of the limited range.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜