/// <summary> /// The index of a descendant of node (i,j). /// The three descendants of one node in x[i,j] are: x[i, Descendant(i+1, j, BranchDirection.Up)], x[i, Descendant(i+1, j, BranchDirection.Middle)] and x[i+1, Descendant(i, j, BranchDirection.Down)] /// </summary> /// <param name="i">The i^{th} point on time grid.</param> /// <param name="j">The j^{th} node at i^{th} time, starting from the bottom as 0.</param> /// <param name="branchDirection">The b direction.</param> /// <returns></returns> public int Descendant(int i, int j, BranchDirection branchDirection) { var branching = Branchings[i]; switch (branchDirection) { case BranchDirection.Down: return(branching.K[j] - branching.JMin - 1); case BranchDirection.Up: return(branching.K[j] - branching.JMin + 1); case BranchDirection.Middle: return(branching.K[j] - branching.JMin); default: throw new ArgumentOutOfRangeException("branchDirection"); } }
public static Vector3 GetVector(int level, BranchDirection branch) { Vector3 position = new Vector3(); LevelModifiers(level); //if (level == 0) return MiddleBase; switch (branch) { case BranchDirection.LEFT: position = LeftBase; break; case BranchDirection.RIGHT: position = RightBase; break; case BranchDirection.MIDDLE: position = MiddleBase; break; } position *= level; position += GetLevelPosition(); return(position); }
/// <summary> /// The branching probability from node (i, j). /// </summary> /// <param name="i">The i^{th} point on time grid.</param> /// <param name="j">The j^{th} node at i^{th} time, starting from the bottom as 0.</param> /// <param name="bDirection">The b direction.</param> /// <returns></returns> public double Probability(int i, int j, BranchDirection bDirection) { return(Branchings[i].Probability[Convert.ToInt32(bDirection)][j]); }
public abstract double Probability(int i, int j, BranchDirection branch);
/// <summary> /// Returns the descendant of node [i,j]. /// The three descendants of one node in x[i,j] are: x[i+1, Descendant(i, j, BranchDirection.Up)], and x[i+1, Descendant(i, j, BranchDirection.Down)] /// </summary> /// <param name="i">The i^{th} time step, starts from 0.</param> /// <param name="j">The j^{th} state.</param> /// <param name="branch">The branching direction, <see cref="BranchDirection"/>. In binomial tree case, it takes value as either Up or Down.</param> /// <returns></returns> public int Descendant(int i, int j, BranchDirection branch) { return(branch == BranchDirection.Down ? j : j + 1); }
public override double Probability(int i, int j, BranchDirection branch) { return(branch == BranchDirection.Up ? PUp : PDown); }