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

51 lines
1.3 KiB
Go

package stats
import "math"
// ZTest performs a one-sample or two-sample Z-test.
//
// For a one-sample Z-test, pass the sample data as data1, nil for data2,
// the known population mean as populationMean, and the known population
// standard deviation as populationStdDev.
//
// For a two-sample Z-test, pass both sample datasets and the known population
// standard deviations. The populationMean parameter is ignored in this case.
//
// Returns the Z statistic and the two-tailed p-value.
//
// https://en.wikipedia.org/wiki/Z-test
func ZTest(data1, data2 Float64Data, populationMean, populationStdDev float64) (z float64, pvalue float64, err error) {
n1 := data1.Len()
if n1 == 0 {
return math.NaN(), math.NaN(), ErrEmptyInput
}
mean1, _ := Mean(data1)
// Two-sample Z-test
if data2 != nil && data2.Len() > 0 {
n2 := data2.Len()
mean2, _ := Mean(data2)
if populationStdDev <= 0 {
return math.NaN(), math.NaN(), ErrBounds
}
se := populationStdDev * math.Sqrt(1.0/float64(n1)+1.0/float64(n2))
z = (mean1 - mean2) / se
} else {
// One-sample Z-test
if populationStdDev <= 0 {
return math.NaN(), math.NaN(), ErrBounds
}
se := populationStdDev / math.Sqrt(float64(n1))
z = (mean1 - populationMean) / se
}
pvalue = 2 * NormSf(math.Abs(z), 0, 1)
return z, pvalue, nil
}