Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "WTANeuron.hpp"
- double WTANeuron::fRand(double Min, double Max) {
- double tmp = (double)rand() / RAND_MAX;
- return Min + tmp * (Max - Min);
- }
- WTANeuron::WTANeuron(int ind) {
- index = ind;
- n = ind;
- register int i;
- w.push_back(fRand(-2., 8.));
- w.push_back(fRand(-2., 2.));
- }
- int WTANeuron::countEuclidMetric(point2 p) {
- register int j;
- double diff2X, diff2Y, diff2;
- diff2X = pow((p.x - w[0]), 2);
- diff2Y = pow((p.y - w[1]), 2);
- diff2 = diff2X + diff2Y;
- euclidMetric = sqrt(diff2);
- return 0;
- }
- int WTANeuron::ScaleMetric() {
- scaledEuclidMetric = n_victories * euclidMetric;
- return 0;
- }
- double WTANeuron::NeighbourFunction() {
- return exp(-n / sigma);
- }
- int WTANeuron::GNGStudy(point2 p) {
- register int i, j, k;
- double diffX, diffY, diff;
- diffX = p.x - w[0];
- diffY = p.y - w[1];
- w[0] += etta * NeighbourFunction() * diffX;
- w[1] += etta * NeighbourFunction() * diffY;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement