public ProgressionValue GetValueAt(DateTime when, bool strictlyEarlier)
        {
            ListItemStats <DateTime, WillingnessSummary> stats = this.searchHelper.FindPreviousItem(when, strictlyEarlier);

            if (stats == null)
            {
                return(null);
            }

            // get some statistics
            DateTime latestDate = stats.Key;
            // compute how long ago that rating was given
            TimeSpan duration = when.Subtract(latestDate);
            // create another date that is twice as far in the past
            DateTime earlierDate = latestDate.Subtract(duration);
            // add up everything that occurred between the earlier day and now
            WillingnessSummary sum = this.searchHelper.CombineBetweenKeys(earlierDate, true, when, !strictlyEarlier);
            double             numParticipations = sum.NumUnpromptedParticipations + sum.NumPromptedParticipations;
            double             numSkips          = sum.NumSkips;
            double             mean         = numParticipations / (numParticipations + numSkips);
            double             weight       = numParticipations + numSkips;
            Distribution       distribution = Distribution.MakeDistribution(mean, 0, weight);
            ProgressionValue   result       = new ProgressionValue(when, distribution);

            return(result);
        }
        private double GetXCoordinate(DateTime when)
        {
            double   x;
            DateTime startDate = this.queryStartDateDisplay.GetDate();

            if (this.xAxisProgression == null)
            {
                DateTime endDate       = this.queryEndDateDisplay.GetDate();
                TimeSpan totalDuration = endDate.Subtract(startDate);
                TimeSpan duration      = when.Subtract(startDate);
                x = duration.TotalSeconds / totalDuration.TotalSeconds;
            }
            else
            {
                ProgressionValue value = this.xAxisProgression.GetValueAt(when, true);
                if (value != null)
                {
                    x = value.Value.Mean;
                }
                else
                {
                    x = 0;
                }
            }
            return(x);
        }
        // returns basically the fraction of the user's time that was spent performing that Doable recently at that date
        public ProgressionValue GetValueAt(DateTime when, bool strictlyEarlier)
        {
            // find the most recent Participation
            ListItemStats <DateTime, Participation> previousStats = this.searchHelper.FindPreviousItem(when, strictlyEarlier);
            DateTime previousEnd;

            // make sure that we have enough data
            if (previousStats == null)
            {
                previousEnd = this.Owner.DiscoveryDate;
            }
            else
            {
                // figure out whether we're in the middle of a participation or not
                Participation previousParticipation = previousStats.Value;
                previousEnd = previousParticipation.EndDate;
            }
            //int index = 2 * this.searchHelper.CountBeforeKey(when, !strictlyEarlier);
            if (previousEnd.CompareTo(when) > 0)
            {
                // we're in the middle of a participation, so the value is zero
                return(new ProgressionValue(when, new Distribution(0, 0, 1)));
            }
            // we're not in the middle of a participation, so the value is the amount of time since the last one ended
            TimeSpan         duration     = when.Subtract(previousEnd);
            Distribution     currentValue = Distribution.MakeDistribution(duration.TotalSeconds, 0, 1);
            ProgressionValue result       = new ProgressionValue(when, currentValue);

            return(result);
        }
        public ProgressionValue GetValueAt(DateTime when, bool strictlyEarlier)
        {
            Prediction       prediction = this.Engine.EstimateParticipationProbability(this.Owner, when);
            ProgressionValue value      = new ProgressionValue(when, prediction.Distribution);

            return(value);
        }
Esempio n. 5
0
        // returns basically the average of the recent rating at that date
        public ProgressionValue GetValueAt(DateTime when, bool strictlyEarlier)
        {
            // find the most recent rating before the given date
            ListItemStats <DateTime, Distribution> latestItem = this.searchHelper.FindPreviousItem(when, true);

            if (latestItem == null)
            {
                return(null);
                //ProgressionValue defaultValue = new ProgressionValue(when, new Distribution(0, 0, 0));
                //return defaultValue;
            }
            // get some statistics
            Distribution latestDistribution = latestItem.Value;
            DateTime     latestDate         = latestItem.Key;
            // compute how long ago that rating was given
            TimeSpan duration = when.Subtract(latestDate);
            // create another date that is twice as far in the past
            DateTime earlierDate = latestDate.Subtract(duration);
            // add up everything that occurred between the earlier day and now
            Distribution sum = this.searchHelper.CombineBetweenKeys(earlierDate, true, when, !strictlyEarlier);
            //int previousCount = this.searchHelper.CountBeforeKey(when, strictlyEarlier);
            ProgressionValue result = new ProgressionValue(when, sum);

            return(result);
        }
        public IEnumerable <ProgressionValue> GetValuesAfter(int indexInclusive)
        {
            IEnumerable <ListItemStats <DateTime, ParticipationAndSummary> > items = this.searchHelper.ItemsFromIndex(indexInclusive);
            List <ProgressionValue> results = new List <ProgressionValue>(items.Count());

            foreach (ListItemStats <DateTime, ParticipationAndSummary> item in items)
            {
                DateTime         when  = item.Key;
                ProgressionValue value = this.GetValueAt(when, false);
                results.Add(value);
            }
            return(results);
        }
Esempio n. 7
0
        public IEnumerable <ProgressionValue> GetValuesAfter(int indexInclusive)
        {
            //int i = indexInclusive;
            List <AbsoluteRating>   ratings = this.ratingsInDiscoveryOrder.GetRange(indexInclusive, this.ratingsInDiscoveryOrder.Count - indexInclusive);
            List <ProgressionValue> results = new List <ProgressionValue>(ratings.Count);

            foreach (AbsoluteRating rating in ratings)
            {
                Distribution     distribution = Distribution.MakeDistribution(rating.Score, 0, 1);
                ProgressionValue value        = new ProgressionValue((DateTime)rating.Date, distribution);
                results.Add(value);
            }
            return(results);
        }
        public ProgressionValue GetValueAt(DateTime when, bool strictlyEarlier)
        {
            ListItemStats <DateTime, ActivitySkip> stats = this.searchHelper.FindPreviousItem(when, strictlyEarlier);

            if (stats == null)
            {
                return(null);
            }
            //return new ProgressionValue(when, new Distribution(), -1);
            ActivitySkip skip         = stats.Value;
            Distribution distribution = Distribution.MakeDistribution(when.Subtract(skip.CreationDate).TotalSeconds, 0, 1);
            //ProgressionValue progressionValue = new ProgressionValue(when, distribution, this.searchHelper.CountBeforeKey(when, !strictlyEarlier));
            ProgressionValue progressionValue = new ProgressionValue(when, distribution);

            return(progressionValue);
        }
Esempio n. 9
0
        public Prediction Guess(DateTime when)
        {
            // get the current inputs
            ProgressionValue currentInput    = this.inputProgression.GetValueAt(when, false);
            Distribution     newDistribution = currentInput.Value;
            // create some result objects
            Prediction   prediction     = new Prediction(null, newDistribution, when, this.Justification);
            Distribution currentValue   = currentInput.Value;
            Distribution output         = currentValue;
            double       startingWeight = output.Weight;
            // correct the weight
            double newWeight = Math.Min(newDistribution.Weight, 10) / Math.Pow(2, this.outputProgression.NumItems / 2);

            prediction.Distribution   = output.CopyAndReweightTo(newWeight);
            prediction.ApplicableDate = when;

            return(prediction);
        }
        public double GetInput(int index)
        {
            Activity         other  = this.activities[index];
            ProgressionValue value  = this.activities[index].ParticipationProgression.GetValueAt(this.when, false);
            double           result = 0;

            if (value != null)
            {
                result = value.Value.Mean;
            }

            if (this.participated != null && this.participated.HasAncestor(other))
            {
                // if we are doing an activity now then we will have done it in a moment
                result *= 2;
            }

            return(result);
        }
        public double GetInput(int index)
        {
            Activity         other  = this.activities[index];
            ProgressionValue value  = this.activities[index].ConsiderationProgression.GetValueAt(this.when, false);
            double           result = 0;

            if (value != null)
            {
                result = value.Value.Mean;
            }
            if (this.participated != null && this.participated.HasAncestor(other))
            {
                // If we are doing an activity then we will have done it in a moment
                result *= 2;
            }
            if (this.suggested != null && this.suggested.HasAncestor(other))
            {
                // If we are suggesting an activity, then most likely we will have skipped it in a moment
                result /= 2;
            }

            return(result);
        }