Esempio n. 1
0
 public void DivideIntervals()
 {
     Interval i1 = new Interval(2.2m, 5.5m);
     Interval i2 = new Interval(2, 10);
     var result = i1 / i2;
     Assert.NotNull(result);
     Assert.AreEqual(1.1f, result.UpperBound);
     Assert.AreEqual(.55f, result.LowerBound);
 }
Esempio n. 2
0
        private Interval GetAdjustedInterests(IList<Interval> expectedInterests)
        {
            Interval result = new Interval(0, 0);
            for (int i = 0; i < expectedInterests.Count; i++)
            {
                result = result + (expectedInterests[i] * this.GetISubN(expectedInterests, i));
            }

            return result;
        }
Esempio n. 3
0
        private Interval AdjustInterval(Interval interval, TwoTuple aggregatedLowerTuple, TwoTuple aggregatedUpperTuple)
        {
            var lowerTupleFactor = this.decimalConverter.ConvertToDecimal(aggregatedLowerTuple);
            var upperTupleFactor = this.decimalConverter.ConvertToDecimal(aggregatedUpperTuple);

            Interval adjustedInterval = lowerTupleFactor < upperTupleFactor ?
                new Interval(lowerTupleFactor, upperTupleFactor) :
                new Interval(upperTupleFactor, lowerTupleFactor);

            var result = interval.LowerBound + (interval.Width * adjustedInterval);
            return result;
        }
        public void CashflowReturnsProperValueIfEmptyIntervals()
        {
            ICompanyValuator valuator = new CompanyValuator();
            var expectedWaccs = new List<Interval>();
            var expectedCashflows = new List<Interval>();

            var result = valuator.Cashflow(expectedCashflows, expectedWaccs);

            var expectedResult = new Interval(0, 0);
            Assert.NotNull(result);
            Assert.AreEqual(expectedResult.LowerBound, result.LowerBound);
            Assert.AreEqual(expectedResult.UpperBound, result.UpperBound);
        }
Esempio n. 5
0
 public static Interval operator *(decimal number, Interval interval)
 {
     Interval result = null;
     if (interval != null)
     {
         result = new Interval()
         {
             LowerBound = interval.LowerBound * number,
             UpperBound = interval.UpperBound * number,
         };
         CheckReorderInterval(result);
     }
     return result;
 }
Esempio n. 6
0
        /// <summary>
        /// Calcualates a company value using the discounted cashflow method.
        /// </summary>
        /// <param name="expectedCashflows">The expected cashflows.</param>
        /// <param name="expectedWaccs">The expected waccs.</param>
        /// <returns>
        /// An interval with the possible value of the company.
        /// </returns>
        /// <exception cref="BizVal.ValuationException">Number of expected cashflow intervals mismatches number of expected WACCs intervals.</exception>
        Interval ICompanyValuator.Cashflow(IList<Interval> expectedCashflows, IList<Interval> expectedWaccs)
        {
            Contract.NotNull(expectedCashflows, "expectedCashflows");
            Contract.NotNull(expectedWaccs, "expectedWaccs");
            if (expectedCashflows.Count != expectedWaccs.Count)
            {
                throw new ValuationException("Number of expected cashflow intervals mismatches number of expected WACCs intervals.");
            }

            Interval result = new Interval();
            for (int i = 0; i < expectedWaccs.Count; i++)
            {
                result = result + (expectedCashflows[i] / this.GetCashflowDivisor(expectedWaccs, i));

            }
            return result;
        }
        public void CashflowReturnsProperValue()
        {
            ICompanyValuator valuator = new CompanyValuator();
            var k1 = new Interval(0.040m, 0.050m);
            var k2 = new Interval(0.045m, 0.060m);
            var k3 = new Interval(0.050m, 0.060m);

            var expectedWaccs = new List<Interval> { k1, k2, k3 };

            var cfl1 = new Interval(4000, 6000);
            var cfl2 = new Interval(3000, 6000);
            var cfl3 = new Interval(2000, 5000);

            var expectedCashflows = new List<Interval> { cfl1, cfl2, cfl3 };

            var result = valuator.Cashflow(expectedCashflows, expectedWaccs);

            var expectedResult = new Interval(8359m, 15343m);

            Assert.NotNull(result);
            Assert.AreEqual(expectedResult.LowerBound, Math.Round(result.LowerBound));
            Assert.AreEqual(expectedResult.UpperBound, Math.Round(result.UpperBound));
        }
Esempio n. 8
0
 public static Interval operator *(Interval interval1, Interval interval2)
 {
     Interval result = null;
     if (interval1 != null && interval2 != null)
     {
         result = new Interval()
         {
             LowerBound = interval1.LowerBound * interval2.LowerBound,
             UpperBound = interval1.UpperBound * interval2.UpperBound,
         };
         CheckReorderInterval(result);
     }
     return result;
 }
Esempio n. 9
0
        private Interval GetISubN(IList<Interval> expectedInterests, int n)
        {
            var result = new Interval(1, 1);
            for (int i = 0; i <= n; i++)
            {
                result = result * (1 / (1 + expectedInterests[i]));
            }

            return result;
        }
Esempio n. 10
0
 public void DivideNullInterval2()
 {
     Interval i1 = new Interval();
     Interval i2 = null;
     Assert.IsNull(i1 / i2);
 }
Esempio n. 11
0
 public void SumNullInterval()
 {
     Interval i1 = null;
     Interval i2 = new Interval();
     var result = i1 + i2;
     Assert.IsNull(result);
 }
Esempio n. 12
0
 public void SumTwoIntervals()
 {
     Interval i1 = new Interval(1, 2.2m);
     Interval i2 = new Interval(0, 2.1m);
     var result = i1 + i2;
     Assert.NotNull(result);
     Assert.AreEqual(1f, result.LowerBound);
     Assert.AreEqual(4.3f, result.UpperBound);
 }
Esempio n. 13
0
 public BindableInterval(Interval interval)
 {
     Contract.NotNull(interval, "interval");
     this.LowerBound = interval.LowerBound;
     this.upperBound = interval.UpperBound;
 }
        public void MixedAnalysisReturnsProperValue()
        {
            ICompanyValuator valuator = new CompanyValuator();

            var substantialValue = 3000m;
            var k1 = new Interval(0.04738m, 0.04872m);
            var k2 = new Interval(0.05425m, 0.05786m);
            var k3 = new Interval(0.05183m, 0.05436m);

            var expectedInterests = new List<Interval> { k1, k2, k3 };

            var cfl1 = new Interval(4898, 5361);
            var cfl2 = new Interval(4166, 5306);
            var cfl3 = new Interval(2499, 3680);

            var expectedBenefits = new List<Interval> { cfl1, cfl2, cfl3 };

            var result = valuator.MixedAnalysis(substantialValue, expectedBenefits, expectedInterests);

            var expectedResult = new Interval(11913m, 14046m);

            Assert.NotNull(result);
            Assert.AreEqual(expectedResult.LowerBound, Math.Round(result.LowerBound));
            Assert.AreEqual(expectedResult.UpperBound, Math.Round(result.UpperBound));
        }
Esempio n. 15
0
 public static Interval operator ^(Interval interval, decimal number)
 {
     Interval result = null;
     if (interval != null)
     {
         result = new Interval()
         {
             LowerBound = (decimal)Math.Pow((double)interval.LowerBound, (double)number),
             UpperBound = (decimal)Math.Pow((double)interval.UpperBound, (double)number),
         };
         CheckReorderInterval(result);
     }
     return result;
 }
Esempio n. 16
0
 private static void CheckReorderInterval(Interval result)
 {
     if (result.LowerBound > result.UpperBound)
     {
         var lowerBound = result.LowerBound;
         result.LowerBound = result.UpperBound;
         result.UpperBound = lowerBound;
     }
 }
Esempio n. 17
0
 /// <summary>
 /// Equalses the specified other.
 /// </summary>
 /// <param name="other">The other.</param>
 /// <returns></returns>
 protected bool Equals(Interval other)
 {
     return this.LowerBound.Equals(other.LowerBound) && this.UpperBound.Equals(other.UpperBound);
 }
Esempio n. 18
0
 private Interval GetCashflowDivisor(IList<Interval> expectedWaccs, int i)
 {
     Interval result = new Interval(1, 1);
     for (int j = 0; j <= i; j++)
     {
         result = result * (1 + expectedWaccs[j]);
     }
     return result;
 }
Esempio n. 19
0
 public Expertise(Interval interval)
 {
     this.Interval = interval;
     this.Opinions = new List<Opinion>();
 }