Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit adb3530

Browse files
committedOct 27, 2024·
feat(math): do not normalize chi_square value.
1 parent 7adbdf9 commit adb3530

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed
 

‎src/math_tools.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ pub fn chi_square(data: &[u8]) -> f64 {
4949
})
5050
.sum();
5151

52-
// Normalize chi-square by the maximum possible value
53-
let chi_square_max = (num_bins as f64) * (data.len() as f64 - 1.0);
54-
chi_square / chi_square_max
52+
chi_square
5553
}
5654
/// Calculates Chi Square of data
5755
#[pyfunction(name = "chi_square")]
@@ -105,7 +103,7 @@ mod tests {
105103

106104
// Expect chi-square to be relatively low for uniform random data
107105
assert!(
108-
chi_square_value < 0.2,
106+
chi_square_value < 300.0,
109107
"Chi-square for random data was too high: {}",
110108
chi_square_value
111109
);
@@ -117,9 +115,8 @@ mod tests {
117115
let non_random_data = vec![42u8; 4096];
118116
let chi_square_value = chi_square(&non_random_data);
119117

120-
// Expect chi-square to be close to 1 for non-random data
121118
assert!(
122-
chi_square_value > 0.8,
119+
chi_square_value == 1044480.0,
123120
"Chi-square for non-random data was too low: {}",
124121
chi_square_value
125122
);
@@ -134,7 +131,7 @@ mod tests {
134131

135132
// Check chi-square for partially random data
136133
assert!(
137-
chi_square_value > 0.2 && chi_square_value < 0.8,
134+
chi_square_value < 275000.0,
138135
"Chi-square for partial random data was outside expected range: {}",
139136
chi_square_value
140137
);

0 commit comments

Comments
 (0)
This repository has been archived.