How to enforce invariants using the type system

My new job has introduced me to Go and I'd like some advice on domain modelling. I'd like to create a type that enforces a particular constraint and have the type be the proof of validity. This type would be used company wide and throughout our system.

For example, creating a subset of the string type with constraints on it's length.A naive approach:

``````var ErrStringTooLong = errors.New("too long")

type Max8String string

func NewMax8String(s string) (Max8String, error) {
lengthOfString := len(s)
if lengthOfString &gt; 8 {
return "", ErrStringTooLong
}
return Max8String(s), nil
}

func main() {
var foo Max8String
foo = "Length more than 8"
}
``````

This obviously allows the constraint enforcement to be bypassed as it relies on convention. I understand exposing an interface to an underlying type but what would an "idiomatic" design of this interface look like?

It may be helpful to know that the true goal is to avoid sanity checks/validation logic throughout the code base AND to not rely on convention if possible.

π︎ 5
π°︎ r/golang
π¬︎
π€︎ u/AlmostNihilist94
π︎ May 09
π¨︎ report
Mass is INVARIANT!!!
π︎ 69
π°︎ r/physicsmemes
π¬︎
π€︎ u/HoloandMaiFan
π︎ Apr 30
π¨︎ report
Polynomials invariant under matrix transformation.

I recently saw an olympiad problem asking to characterize all polynomials P satisfying P(x,y)=P(x+2y,x+y). I tried to generalize this: given a square matrix A, find all polynomials P satisfying P(x)=P(Ax) for all vectors x. This is not too hard to do for diagonalizable matrices, but I couldn't do the general case. Are there any sources on such a topic?

π︎ 94
π°︎ r/math
π¬︎
π€︎ u/SupercaliTheGamer
π︎ Apr 17
π¨︎ report
Fixed effect vs Random effect with time invariant variables

Hi guys,

So im working on my thesis, im doing a binary data panel regression.

I did the Hausman test to see if I should use fixed effects or random effects for a logit regression. The test is telling me that the correct one to use is the fixed effects, however when I run the model, i get this result:

2136 groups (6408 obs = 3/4 of the individuals) dropped because of all positive or all negative outcomes and also 3 important variables are omitted because they have no within-group variance, the sex of the individual and the fathers and mothers education.

My question is if this problem is enough reason to ignore the Hausman test, change the model and run one with random effects or maybe there is some other test that i could do, im a bit clueless on how to proceed now.

Also notice that with the random effects all my variables are significant, under fixed effects only one of my variables is significant.

π︎ 4
π°︎ r/econometrics
π¬︎
π€︎ u/Matiuv9
π︎ May 25
π¨︎ report
Mass is INVARIANT!!!
π︎ 30
π¬︎
π€︎ u/HoloandMaiFan
π︎ Apr 30
π¨︎ report
LIFE: Lighting Invariant Flow Estimation - Augmented Reality Demo (NVIDIA) v.redd.it/1po6zdkws3t61
π︎ 77
π°︎ r/computervision
π¬︎
π€︎ u/AR_MR_XR
π︎ Apr 14
π¨︎ report
[2102.11600] ASAM: Adaptive Sharpness-Aware Minimization for Scale-Invariant Learning of Deep Neural Networks arxiv.org/abs/2102.11600
π︎ 12
π°︎ r/MachineLearning
π¬︎
π€︎ u/evanatyourservice
π︎ Apr 12
π¨︎ report
LIFE: Lighting Invariant Flow Estimation - Augmented Reality Demo (NVIDIA) v.redd.it/1po6zdkws3t61
π︎ 83
π°︎ r/AR_MR_XR
π¬︎
π€︎ u/AR_MR_XR
π︎ Apr 14
π¨︎ report
Aggregate Design: Using Invariants as a Guide youtube.com/watch?v=64ngPβ¦
π︎ 64
π°︎ r/dotnet
π¬︎
π€︎ u/codeopinion
π︎ Apr 14
π¨︎ report
LIFE: Lighting Invariant Flow Estimation - Augmented Reality Demo (NVIDIA) v.redd.it/1po6zdkws3t61
π︎ 60
π°︎ r/augmentedreality
π¬︎
π€︎ u/AR_MR_XR
π︎ Apr 20
π¨︎ report
Knot Invariants in Minecraft youtu.be/GEZSM8KnFD0
π︎ 14
π°︎ r/CasualMath
π¬︎
π︎ May 11
π¨︎ report
LIFE: Lighting Invariant Flow Estimation (NVIDIA) v.redd.it/1po6zdkws3t61
π︎ 123
π°︎ r/nvidia
π¬︎
π€︎ u/AR_MR_XR
π︎ Apr 14
π¨︎ report
How to make CNN more scale invariant?

Let's say I want to classify some digits or letters but on images they have varying scale, some of them take up a whole image, others are much smaller.

What can I do to make my model more scale invariant in this case? Cropping seems like a good start but I wouldn't want to crop an image that has a very large symbol in it, because for example cropping out from image of 7 could make it look like 1 if I get rid of the top part.

Another idea is to preprocess data, but I cannot do it as the test set will also contain various scales. And more importantly I don't want to do it, if there's a technique that doesn't rely on preprocessing I'd like to learn about it just to learn something new.

What can I use here? I've heard and briefly read about stuff like pyramids, would this apply here? Or do you have any other ideas I could try out?

π︎ 3
π¬︎
π€︎ u/Gabe_The_Human
π︎ Apr 30
π¨︎ report
Why exactly are wavefunctions "invariant" under a change of phase? Is it because elements of the space of square integrable functions from βΒ³ to β that differ by a phase are identical? That is, the same element in LΒ²(βΒ³)?
π︎ 4
π¬︎
π€︎ u/SK209920
π︎ Mar 28
π¨︎ report
Iβm supposed to find m st y=mx is invariant under the transformation below. Iβm confused as to why not all real values of m work. How does the mark scheme conclude that ONLY +/-1 work? am I missing something?
π︎ 25
π¬︎
π︎ Mar 26
π¨︎ report
"An EPIC (Equivalent-Policy Invariant Comparison) way to evaluate reward functions", Gleave et al 2021 (offline comparison of reward functions) bair.berkeley.edu/blog/20β¦
π︎ 6
π°︎ r/ControlProblem
π¬︎
π€︎ u/gwern
π︎ Apr 29
π¨︎ report
Rotation invariant CNN embeddings

For the purpose of my university project, I want to achieve the following result.

Given 2 images where one in a rotated version of the other. I want output feature vectors to be as close as possible.

For this purpose, I am maximizing cosine similarity between them, but from the first iteration, it gives an output close to 1.

Do you have any suggestions on how can I solve this problem?

π︎ 14
π°︎ r/computervision
π¬︎
π€︎ u/IntInstance
π︎ Mar 01
π¨︎ report
Characterization of Time-variant and Time-invariant Assessment of Suicidality on Reddit using C-SSRS [preprint] arxiv.org/pdf/2104.04140.β¦
π︎ 2
π¬︎
π€︎ u/MFA_Nay
π︎ Apr 16
π¨︎ report
Error Invariant Failed

Any idea why I can't connect my Binance Chain Wallet to Pancakeswap? Or what 'Error Invariant Failed' means?

https://preview.redd.it/cae7msb2qzm61.png?width=1920&format=png&auto=webp&s=6347d140f056d8f403bba6440340095681ac0d79

π︎ 2
π°︎ r/pancakeswap
π¬︎
π€︎ u/simonkohtao
π︎ Mar 14
π¨︎ report
Knot Invariants in Minecraft youtu.be/GEZSM8KnFD0
π︎ 3
π°︎ r/3Blue1Brown
π¬︎
π︎ May 12
π¨︎ report
Loop invariants and Structural Induction

I've been thinking a lot of loop invariants and how they relate to structural induction. Sounds like they're 2 sides of the same coin.

Would it be fair to say any proof for an iterative algorithm I can make using a loop invariant, I should be able to make for the same algorithm expressed recursively using structural induction?

Also, would one method be preferred over the other when proving a property about a set or other recursively defined structure? As an example, let's say something like the merge algorithm in merge sort. I can see using both loop invariants and structural induction to prove its correctness depending on how I express the problem.

π︎ 5
π°︎ r/algorithms
π¬︎
π€︎ u/RazerWolf
π︎ Mar 21
π¨︎ report
Data-Driven Inference of Representation Invariants: a subject that could become relevant to AGI youtube.com/watch?v=sOkDEβ¦
π︎ 6
π°︎ r/agi
π¬︎
π€︎ u/pentin0
π︎ Apr 02
π¨︎ report
[2102.11600] ASAM: Adaptive Sharpness-Aware Minimization for Scale-Invariant Learning of Deep Neural Networks arxiv.org/abs/2102.11600
π︎ 2
π°︎ r/deeplearning
π¬︎
π€︎ u/evanatyourservice
π︎ Apr 12
π¨︎ report
"An EPIC (Equivalent-Policy Invariant Comparison) way to evaluate reward functions", Gleave et al 2021 (offline comparison of reward functions) bair.berkeley.edu/blog/20β¦
π︎ 8
π¬︎
π€︎ u/gwern
π︎ Apr 29
π¨︎ report
You'll enjoy this series called Strangers, where an "invariant" is drawn to Earth to fight a creature, and then becomes the glue that holds together a team of extraterrestrial beings globalcomix.com/c/strangeβ¦
π︎ 25
π°︎ r/SciFiScroll
π¬︎
π€︎ u/nimloth
π︎ Mar 16
π¨︎ report
Aggregate Design: Using Invariants as a Guide youtube.com/watch?v=64ngPβ¦
π︎ 2
π°︎ r/CodeOpinion
π¬︎
π€︎ u/codeopinion
π︎ Apr 14
π¨︎ report
This looks like the equation for Energy-momentum relation. it relates energy to invariant mass, which is the portion of mass of an object/system that is independent of the overall system. I think this was foreshadowing of Vison's growing autonomy from Wandas control. Just a thought.
π︎ 15
π°︎ r/WANDAVISION
π¬︎
π€︎ u/SynthesizedSquawk
π︎ Feb 05
π¨︎ report
Iβm supposed to find m st y=mx is invariant under the transformation. Iβm confused as to why not all real values of m work. How does the mark scheme conclude that ONLY +/-1 work? Am I missing something?
π︎ 7
π°︎ r/6thForm
π¬︎
π︎ Mar 26
π¨︎ report
Zero To Production In Rust, Part Six: Using Types To Guarantee Domain Invariants lpalmieri.com/posts/2020-β¦
π︎ 166
π°︎ r/rust
π¬︎
π€︎ u/LukeMathWalker
π︎ Dec 11 2020
π¨︎ report