* 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>
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package stats
|
|
|
|
import (
|
|
"math"
|
|
)
|
|
|
|
// ProbGeom generates the probability for a geometric random variable
|
|
// with parameter p to achieve success in the interval of [a, b] trials
|
|
// See https://en.wikipedia.org/wiki/Geometric_distribution for more information
|
|
func ProbGeom(a int, b int, p float64) (prob float64, err error) {
|
|
if (a > b) || (a < 1) {
|
|
return math.NaN(), ErrBounds
|
|
}
|
|
|
|
q := 1 - p // probability of failure
|
|
|
|
if a == b {
|
|
return p * math.Pow(q, float64(a-1)), nil
|
|
}
|
|
|
|
// closed form of the sum p*q^(k-1) over k = a..b; expm1/log1p keep
|
|
// 1-q^n accurate where direct subtraction would cancel
|
|
return math.Pow(q, float64(a-1)) * -math.Expm1(float64(b-a+1)*math.Log1p(-p)), nil
|
|
}
|
|
|
|
// ProbGeom generates the expectation or average number of trials
|
|
// for a geometric random variable with parameter p
|
|
func ExpGeom(p float64) (exp float64, err error) {
|
|
if (p > 1) || (p < 0) {
|
|
return math.NaN(), ErrNegative
|
|
}
|
|
|
|
return 1 / p, nil
|
|
}
|
|
|
|
// ProbGeom generates the variance for number for a
|
|
// geometric random variable with parameter p
|
|
func VarGeom(p float64) (exp float64, err error) {
|
|
if (p > 1) || (p < 0) {
|
|
return math.NaN(), ErrNegative
|
|
}
|
|
return (1 - p) / math.Pow(p, 2), nil
|
|
}
|