- Pages
- Quant's Toolbox and Ideas
- Chaos kernel function using the logistic map?

- Public
- History
- 1 like
sachinarora liked this 2537 days ago

Last updated 2574 days ago by JohnLast Comments (20)

I made some experiments with different kernels and I would like to share among friends some ideas.

**Well it is about to use a function expressing chaotic behaviour itself as a kernel.**

The simplest thing was to look at the most simple logistic map.

That is the equation of the logistic map. What we can do with that.

What is interesting for us is the parameter r. If we vary the parameter we will have different behaviour (sensitivity of the initial conditions). I keep it short here but we can get some very interesting stretching-and-folding structures , please look at the Wikipedia article.

От Поле за пускане |

#property copyright "Copyright 2011, MetaQuotes Software Corp."

#property link "http://www.mql5.com"

#property version "1.00"

//--- input parameters

input double x=0.5;input double r=1;

//+------------------------------------------------------------------+

//| Tester function |

//+------------------------------------------------------------------+

double OnTester()

{

//---

double w0 = r*x*(1-x);

double w1 = r*w0*(1-w0);

double w2 = r*w1*(1-w1);

double w3 = r*w2*(1-w2);

double w4 = r*w3*(1-w3);

//---

return(w2);

}

This is the code that can be used to make mathematical simulations in Metatrader 5.

Here I do not use for and while operators, because I want the code to be mathematically explicit for the non coders here.

Well what we can do next and yes we can replace the x by the gaussian kernel (the gaussian kernet iteslf has x and y and the output varies from 0 to 1). So it is fine let take a look what we get.

От Поле за пускане |

The code is here:

#property copyright "Copyright 2011, MetaQuotes Software Corp."

#property link "http://www.mql5.com"

#property version "1.00"

//--- input parameters

input double x=-3.0;

input double y=-3.0;

input double r=1;

//+------------------------------------------------------------------+

//| Tester function |

//+------------------------------------------------------------------+

double OnTester()

{

//---

double w0 = MathExp(-x*x-y*y);

double w1 = r*w0*(1-w0);

double w2 = r*w1*(1-w1);

double w3 = r*w2*(1-w2);

double w4 = r*w3*(1-w3);

//---

return(w2);

So in the chaos kernel we have 3 parameters (look at the comments). x and y are coming from the gaussian kernel the r is from the logistic map equation.

But there is something more, lol, look at the recurrence relation, we can use the first cycle w1, the second, w2, the thirs w3 (it is up to us to choose how far we can go). So w2 is more complex that w0 and w3 has a more complex structure than w2.

The logistic map stretching-and-folding structures combined with an input coming gaussian kernel are able to produce weird things lol.

От Поле за пускане |

So can we use this as a kernel? The r parameter is the kernel's chaotic parameter than can be limited or expanded.

In my imagination the real science fiction artificial intelligence need to use some kind of chaotic parameter, stepping from the deterministic to the non deterministic.

The question is:

Can we use kernels with chaotic behavior to model chaotic systems?

I think yes too, if that is true that is another kernel trick.

## Comments

The chaotic kernel looks like this. You can use w1, w2,w3 or w4 etc. In the example here we use w3.

For x1,x2,x3,x4 I use from -3 to 3 with step size 0.01

For r I use from 1 to 3.54, but you can decide how chaotic the kernel will be.

Phenomenal

So, this is the true kernel perceptron. very good.

Why in MQL5 and not in MQL4 ?

and what is the value for Gamma ??

The problem is how to fetch the appropriate value for r, too

you wrote "For r I use from 1 to 3.54" . Where r is defined ? in which equation ? which are the relationship between r and gamma ?

It is in mt5 because you can plot the mathematical function, so you can make visualisations very simply.

r is defined in the wikipewdia article. If the r is low there is no chaos, if you increase it above certain levels you get chaotic.

gamma is not needed, this is a mod.

Here I just want to share a piece of code for mt4 for the chaotic kernel. Can we use indeterministic functions as kernels? Maybe this is the first one LOL.

Here I just want to share a piece of code for mt4 for the chaotic kernel. Can we use indeterministic functions as kernels? Maybe this is the first one LOL.

As discrete-time systems are described in terms of difference equations, this looks like a good but radical idea, because the system cannot be efficiently represented by a set of equations, or because no such set of equations exists.

Please check the code.

Here I just want to share a piece of code for mt4 for the chaotic kernel. Can we use indeterministic functions as kernels? Maybe this is the first one LOL.

As discrete-time systems are described in terms of difference equations, this looks like a good but radical idea, because the system cannot be efficiently represented by a set of equations, or because no such set of equations exists.

After just a glance to this code, I think

double p1 = iCustom(TimeFrame,Symbol(),"PFE",x5,true,5,0,0);

double p2 = iCustom(TimeFrame,Symbol(),"PFE",x6,true,5,0,0);

double p3 = iCustom(TimeFrame,Symbol(),"PFE",x7,true,5,0,0);

double p4 = iCustom(TimeFrame,Symbol(),"PFE",x8,true,5,0,0);

should be replaced by

double p1 = iCustom(TimeFrame,Symbol(),"PFE",5,true,5,0,l+x5);

double p2 = iCustom(TimeFrame,Symbol(),"PFE",5,true,5,0,l+x6);

double p3 = iCustom(TimeFrame,Symbol(),"PFE",5,true,5,0,l+x7);

double p4 = iCustom(TimeFrame,Symbol(),"PFE",5,true,5,0,l+x8);

the l iteration is for the plotting

I will test the new indie before uploading it

all the best

You mean to use the same lenght but with time lag?

Yes definitely tat is a possibility, even in Neuroshell Daytrader one of the default systems is using linear regression indicators with time lag to make predictions.

This code is wrong. But I think you get the idea.

This is 3d picture of the logistic map. Logistic map as a kernel. Why not?

This code actually plots the logistic map, but as you will see the two first numbers are missing: first and second:

#property copyright "Copyright 2011, MetaQuotes Software Corp."

#property link "http://www.mql5.com"

#property version "1.00"

//--- input parameters

input double x;

input int limitmap =10;

input double r=1;

Here is the Logistic map in the Metatrader 5 tester.

So the idea as as follows:

Given the logistic map equation:

we can vary three parameters and to use this as a kernel:

1. We can vary x (from 0 to 1 with step 0.01, or 0.001 for example): this is giving us the initial conditions

2. We can vary the r parameter (from 1 to with step 0.01, or 0.001 for example) this is the parameter governing the chaos.

rapproximately 3.57 is the onset of chaos, so we can limit from 1 to 3.3. And of course finally we can vary the limitmap parameter governing the number of iterations. This is the third parameter for the difference equation. Here I need some help because the code I made is missing to plot the values of first two iterations and it is beginning to plot from the third.

So We can call this chaos kernel, in fact I do not know even if that has a name. I did not find in the available litterature anything of this kind. So it is possible that this appears on this site for the first time. I know crazy it is.

The two MAIN ideas ARE:

- TO USE RECURRENT DIFFERENCE EQUATION

- TO USE SOME PORTION OF CHAOS OF THE KERNEL ITSELF

If that is true with just one kernel we have something extremely powerfull. And even more, there are many other maps waiting to be exploited as kernels.

So this is opening a door, for a new paradigm for the machine learning.

I am using here the logistic map because it is something extremely simple but generating extremely complex mathematical behavior.

Using chaos kernel to harness the chaos itself. Why not after all?

Another possibility is to use string equations for building dynamic kernel structures, but this is not as simple as the difference equations.

The difference equations are computationally light.

Finally the best code by now is those proposed by vgc:

Sometimes we would need more than one weight.

how to know when to need another weight ?

You can chech here

http://beathespread.com/file/view/10551/chaos-kernel-spinal-implant

I would use this, in fact the stupid mistake comes from simple mathematics, whenever we multiply by the same ammount on the left we get the same result if on the right side we have 0.

You can verify this by manually replacing the weight by different constants that you will get the same results in this case.

However when we touch a single variable that affects everything like in the neural asctrend a single kernel is enough.