-
Notifications
You must be signed in to change notification settings - Fork 0
/
SUSStudy.cs
142 lines (119 loc) · 4.98 KB
/
SUSStudy.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
namespace Statistics.Services;
/// <summary>
/// Represents a system usability scale study (name, study score (average of scores), scores, and raw item scores.
/// So this is basically all the information for one variable (system) in the tool.
/// </summary>
public struct SUSStudy
{
/// <summary>
/// The name of this SUS study (a group of SUS questionnaires: here our variable)
/// </summary>
public string SystemName { get; private set; }
/// <summary>
/// The SUS study score (the average of all SUS scores of the sudy)
/// </summary>
public float StudyScore { get; }
/// <summary>
/// The standard deviation of the SUS study score
/// </summary>
public float StandardDeviation { get; }
/// <summary>
/// The minimum SUS score
/// </summary>
public float MinScore { get; }
/// <summary>
/// The maximum SUS score
/// </summary>
public float MaxScore { get; }
/// <summary>
/// The first quartile of the SUS scores (Exclusive Median)
/// </summary>
public float FirstQuartile { get; set; }
/// <summary>
/// The median of the SUS scores
/// </summary>
public float MedianScore { get; }
/// <summary>
/// The third quartile of the SUS scores (Exclusive Median)
/// </summary>
public float ThirdQuartile { get; }
/// <summary>
/// A List with all SUS scores
/// </summary>
public List<float> SUSScores { get; }
/// <summary>
/// A List of Lists which each hold the 10 raw SUS questionnaire Likert Scale values
/// </summary>
public List<List<float>> RawItemScores { get; }
/// <summary>
/// The constructor of the SUS study
/// </summary>
/// <param name="systemName">Name of the system (variable)</param>
/// <param name="rawItemScores">A List of Lists which each hold the 10 raw SUS questionnaire Likert Scale values</param>
public SUSStudy(string systemName, List<List<float>> rawItemScores)
{
// Store the name and raw SUS item data
SystemName = systemName;
RawItemScores = rawItemScores;
// Calculate the SUS scores
SUSScores = CalculateSusScores(RawItemScores);
// Calculate the SUS study score
StudyScore = SUSScores.Average();
StudyScore = (float)Math.Round(StudyScore, 2);
// Calculate the sample standard deviation and round it to 2 decimal places
StandardDeviation = CalculateStandardDeviation(SUSScores);
StandardDeviation = (float)Math.Round(StandardDeviation, 2);
// Calculate the min and max
MinScore = SUSScores.Min();
MaxScore = SUSScores.Max();
// Calculate quartiles
List<float> sortedSusScores = new(SUSScores);
sortedSusScores.Sort();
int n = sortedSusScores.Count;
// Calculate the first quartile, median, and third quartile using the static QuartileCalculator class
FirstQuartile = QuartileCalculator.GetQuartile(sortedSusScores, 0.25f);
MedianScore = QuartileCalculator.GetQuartile(sortedSusScores, 0.5f);
ThirdQuartile = QuartileCalculator.GetQuartile(sortedSusScores, 0.75f);
return;
// Helper function to calculate the sample standard deviation of the SUS study score
// [ s = \sqrt{\frac{\sum (x_i - \bar{x})^2}{n - 1}} ]
//
// Where:
// ( s ) is the sample standard deviation.
// ( x_i ) are the individual data points.
// ( \bar{x} ) is the mean of the data points.
// ( n ) is the number of data points.
float CalculateStandardDeviation(List<float> susScores)
{
float sum = 0;
float mean = susScores.Average();
foreach (float score in susScores)
sum += (score - mean) * (score - mean);
return (float)Math.Sqrt(sum / (susScores.Count - 1));
}
}
/// <summary>
/// Calculates the SUS scores for a given list of raw item scores.
/// </summary>
/// <param name="rawItemScores">A List of Lists containing the raw SUS questionnaire Likert Scale values for each item.</param>
/// <returns>A List of calculated SUS scores.</returns>
private static List<float> CalculateSusScores(List<List<float>> rawItemScores)
{
// Create a list to store the SUS scores
List<float> susScores = new();
// for each row of raw item scores, calculate the SUS score
foreach (List<float> itemScores in rawItemScores)
{
float sum = 0;
for (int i = 0; i < itemScores.Count; i++)
if (i % 2 == 0) // Odd-numbered questions (1, 3, 5, 7, 9)
sum += itemScores[i] - 1;
else // Even-numbered questions (2, 4, 6, 8, 10)
sum += 5 - itemScores[i];
float susScore = sum * 2.5f;
susScores.Add(susScore);
}
// return the list of SUS scores
return susScores;
}
}