private List <ScatterPoint> GetScatterPoints(Subject[] allSubjects, Gender gender) { int[,] weights = new int[101, 101]; foreach (Subject subject in allSubjects.Where(x => x.Gender == gender)) { HemispherePercentage hemispherePercentage = testEvaluator.Evaluate(subject); int leftPercentage = (int)hemispherePercentage.LeftPercentage; int age = subject.Age; weights[leftPercentage, age]++; } List <ScatterPoint> maleScatterPoints = new List <ScatterPoint>(); for (int perc = 0; perc < weights.GetLength(0); perc++) { for (int age = 0; age < weights.GetLength(1); age++) { int weight = weights[perc, age]; if (weight > 0) { maleScatterPoints.Add(new ScatterPoint(perc, age, weight)); } } } return(maleScatterPoints); }
public HemispherePercentage Evaluate(Subject subject) { HemispherePercentage percentage = new HemispherePercentage(); int numberOfQuestions = subject.QuestionAnswers.Count(); int answersForRight = subject.QuestionAnswers.Where(qa => qa.Question.Hemisphere == Hemisphere.Right && qa.Answer == true).Count() + subject.QuestionAnswers.Where(qa => qa.Question.Hemisphere == Hemisphere.Left && qa.Answer == false).Count(); int answersForLeft = subject.QuestionAnswers.Where(qa => qa.Question.Hemisphere == Hemisphere.Left && qa.Answer == true).Count() + subject.QuestionAnswers.Where(qa => qa.Question.Hemisphere == Hemisphere.Right && qa.Answer == false).Count(); double rightPerc = Math.Round(answersForRight / ((numberOfQuestions) * 0.01), 2); double leftPerc = 100 - rightPerc; if (Double.IsNaN(rightPerc)) { percentage.RightPercentage = 0; } else { percentage.RightPercentage = rightPerc; } if (Double.IsNaN(leftPerc)) { percentage.LeftPercentage = 0; } else { percentage.LeftPercentage = leftPerc; } return(percentage); }