Skip to content

Commit

Permalink
use moment instead of sum abs2
Browse files Browse the repository at this point in the history
Co-authored-by: David Widmann <[email protected]>
  • Loading branch information
Marek Kaluba and devmotion authored Oct 23, 2023
1 parent 475498d commit 135e43a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/shapiro_wilk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ end

function unsafe_swstat(X::AbstractVector{<:Real}, A::AbstractVector{<:Real})
AX = @inbounds dot(view(A, 1:length(X)), X)
m = mean(X)
= sum(x -> abs2(x - m), X)
= moment(X, 2)
W = AX^2 /
return min(W, one(W)) # to guard against numeric errors
end
Expand Down

0 comments on commit 135e43a

Please sign in to comment.