Files
3f5b3cdd98 feat: add configurable SMTP HELO hostname (#2146)
* feat: add configurable SMTP HELO hostname

Allow the SMTP HELO/EHLO hostname to be configured separately from
the SMTP server hostname.

This is useful when the SMTP server requires clients to identify
themselves with a fully qualified hostname different from the server
address.

* chore: remove vendored dependency changes

* Bump go-pkgz/notify to v1.4.0 and document SMTP_HELO_HOST

The HELOHost field lands in go-pkgz/notify v1.4.0, so the branch needs the
bump to compile; v1.3.0 in master has no such field. The example module is
tidied alongside, as any change to backend/go.mod requires.

Documents the parameter in the parameters table and, separately, in the email
setup page: what it does, that leaving it unset keeps the previous `localhost`
greeting, and the case it exists for, a relay refusing the greeting under
Postfix `reject_non_fqdn_helo_hostname`.

Also records the current limit: verification emails for email authentication
go through go-pkgz/auth's own sender, which has no equivalent setting, so the
greeting there is unchanged.

* Bump go-pkgz/auth to v2.2.0 and apply SMTP_HELO_HOST to verification email

The verification email sender had no way to set the greeting, so a relay that
refuses the HELO would accept notifications and still reject sign-in emails.
EmailParams gains HELOHost in go-pkgz/auth v2.2.0, so the same SMTP_HELO_HOST
now drives both paths.

The example module is tidied alongside, as any change to backend/go.mod
requires.

---------

Co-authored-by: oli <someone@somewhere.tld>
Co-authored-by: Dmitry Verkhoturov <paskal.07@gmail.com>
2026-08-19 02:52:39 -05:00

58 lines
1.4 KiB
Go

package stats
import "math"
// KendallTau calculates Kendall's tau-b rank correlation coefficient
// between two variables. Tau-b corrects for ties, matching the values
// produced by SciPy's kendalltau and pandas' corr(method="kendall").
// Pairs are compared with a simple O(n^2) loop for clarity.
func KendallTau(data1, data2 Float64Data) (float64, error) {
l1 := data1.Len()
l2 := data2.Len()
if l1 == 0 || l2 == 0 {
return math.NaN(), ErrEmptyInput
}
if l1 != l2 {
return math.NaN(), ErrSize
}
// Count concordant and discordant pairs along with pairs
// tied only in the first or only in the second variable.
var concordant, discordant, tiedX, tiedY float64
for i := 0; i < l1; i++ {
for j := i + 1; j < l1; j++ {
dx := data1[i] - data1[j]
dy := data2[i] - data2[j]
switch {
case dx == 0 && dy == 0:
// Pairs tied in both variables are excluded
case dx == 0:
tiedX++
case dy == 0:
tiedY++
case (dx > 0) == (dy > 0):
concordant++
default:
discordant++
}
}
}
// tau-b = (C - D) / sqrt((C + D + Tx) * (C + D + Ty))
denominator := math.Sqrt((concordant + discordant + tiedX) * (concordant + discordant + tiedY))
if denominator == 0 {
return 0, nil
}
return (concordant - discordant) / denominator, nil
}
// KendallTau calculates Kendall's tau-b rank correlation coefficient
// between two variables.
func (f Float64Data) KendallTau(d Float64Data) (float64, error) {
return KendallTau(f, d)
}