RLPark 1.0.0
Reinforcement Learning Framework in Java

PVectors.java

Go to the documentation of this file.
00001 package rlpark.plugin.rltoys.math.vector.implementations;
00002 
00003 import rlpark.plugin.rltoys.math.vector.RealVector;
00004 
00005 
00006 public class PVectors {
00007   static public double mean(PVector vector) {
00008     double[] a = vector.data;
00009     double sum = 0.0;
00010     for (int i = 0; i < vector.size; i++)
00011       sum += a[i];
00012     return sum / vector.size;
00013   }
00014 
00015   public static PVector multiplySelfByExponential(PVector result, double factor, RealVector other) {
00016     return multiplySelfByExponential(result, factor, other, 0);
00017   }
00018 
00019   public static PVector multiplySelfByExponential(PVector result, double factor, RealVector other, double min) {
00020     if (other instanceof SVector)
00021       return multiplySelfByExponential(result, factor, (SVector) other, min);
00022     for (int i = 0; i < result.size; i++)
00023       result.data[i] = Math.max(min, result.data[i] * Math.exp(factor * other.getEntry(i)));
00024     return result;
00025   }
00026 
00027   public static PVector multiplySelfByExponential(PVector result, double factor, SVector other, double min) {
00028     int[] activeIndexes = other.getActiveIndexes();
00029     for (int i = 0; i < other.nonZeroElements(); i++) {
00030       int index = activeIndexes[i];
00031       result.data[index] = Math.max(min, result.data[index] * Math.exp(factor * other.values[i]));
00032     }
00033     return result;
00034   }
00035 }
 All Classes Namespaces Files Functions Variables Enumerations
Zephyr
RLPark