24 lines
815 B
TypeScript
24 lines
815 B
TypeScript
|
import { Task } from "../models/task";
|
||
|
import { Project } from "../models/project";
|
||
|
|
||
|
export function getTaskWeightedMean(t: Task): number {
|
||
|
return (t.estimations.optimistic + (4*t.estimations.likely) + t.estimations.pessimistic) / 6;
|
||
|
}
|
||
|
|
||
|
export function getTaskStandardDeviation(t: Task): number {
|
||
|
return (t.estimations.pessimistic - t.estimations.optimistic) / 6;
|
||
|
}
|
||
|
|
||
|
export function getProjectWeightedMean(p : Project): number {
|
||
|
return Object.values(p.tasks).reduce((sum: number, t: Task) => {
|
||
|
sum += getTaskWeightedMean(t);
|
||
|
return sum;
|
||
|
}, 0);
|
||
|
}
|
||
|
|
||
|
export function getProjectStandardDeviation(p : Project): number {
|
||
|
return Math.sqrt(Object.values(p.tasks).reduce((sum: number, t: Task) => {
|
||
|
sum += Math.pow(getTaskStandardDeviation(t), 2);
|
||
|
return sum;
|
||
|
}, 0));
|
||
|
}
|