Ejemplo n.º 1
0
        public static double calculateVarAvg(EpisodeData episode, int varIndex)
        {
            if (varIndex < 0 || episode.steps.Count == 0)
            {
                return(0.0);
            }
            double avg = 0.0;

            foreach (StepData step in episode.steps)
            {
                avg += step.data[varIndex];
            }
            return(avg / episode.steps.Count);
        }
Ejemplo n.º 2
0
        public static double calculateStdDev(EpisodeData episode, int varIndex)
        {
            if (varIndex < 0 || episode.steps.Count == 0)
            {
                return(0.0);
            }
            double avg = calculateVarAvg(episode, varIndex);
            double sum = 0.0, diff;

            foreach (StepData step in episode.steps)
            {
                diff = step.data[varIndex] - avg;
                sum  = diff * diff;
            }
            return(Math.Sqrt(sum / episode.steps.Count));
        }
Ejemplo n.º 3
0
        public static double calculateMax(EpisodeData episode, int varIndex)
        {
            if (varIndex < 0 || episode.steps.Count == 0)
            {
                return(0.0);
            }
            double max = episode.steps[0].data[varIndex];

            foreach (StepData step in episode.steps)
            {
                if (step.data[varIndex] > max)
                {
                    max = step.data[varIndex];
                }
            }
            return(max);
        }
Ejemplo n.º 4
0
        public static ExperimentData load(string logFilename)
        {
            ExperimentData experimentData = new ExperimentData();

            try
            {
                FileStream logFile = File.OpenRead(logFilename);
                using (BinaryReader binaryReader = new BinaryReader(logFile))
                {
                    experimentData.readExperimentLogHeader(binaryReader);
                    for (int i = 0; i < experimentData.numEpisodes; i++)
                    {
                        EpisodeData episodeData = new EpisodeData();
                        experimentData.episodes.Add(episodeData);

                        episodeData.readEpisodeHeader(binaryReader);

                        StepData stepData  = new StepData();
                        bool     bLastStep = stepData.readStep(binaryReader, episodeData.numVariablesLogged);

                        while (!bLastStep)
                        {
                            //we only add the step if it's not the last one
                            //last steps don't contain any info but the end marker
                            episodeData.steps.Add(stepData);

                            stepData  = new StepData();
                            bLastStep = stepData.readStep(binaryReader, episodeData.numVariablesLogged);
                        }
                    }
                }
                logFile.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            return(experimentData);
        }