On Mon, 24 Feb 2020 at 17:47, Aaron Hall via Python-ideas <python-ideas@python.org> wrote: > > The context for this is statistics , so I'll quote Wolfram on tilde in the > context of statistics: http://mathworld.wolfram.com/Tilde.html > > "In statistics, the tilde is frequently used to mean "has the distribution > (of)," for instance, X∼N(0,1) means "the stochastic (random) variable X has > the distribution N(0,1) (the standard normal distribution). If X and Y are > stochastic variables then X∼Y means "X has the same distribution as Y." > > So X~Y is an assertion of a relationship between X and Y. Sympy has an entire > module filled with these distributions. But maybe it's more useful to say `Z > = Normal('Z', 0, 1)` instead of `Z = Z ~ Normal(0, 1)` or maybe `Z ~= > Normal(0, 1)` (Z example from docs, latter tilde examples are mine).
Speaking as a SymPy contributor it isn't clear to me what you expect tilde would be used for in SymPy (although I'm sure it would get used for lots of things if it existed). The problem with the two examples shown is that they require Z to exist already but if you need to create Z you might as well just create it as Z=Normal(...). Something that stands out to me in what you've said is that X~Y is a "relationship between X and Y". In all mathematical contexts I know of ~ is a relation rather than an operation. In fact ~ is often used as *the* generic symbol for talking about relations in the abstract e.g.: https://en.wikipedia.org/wiki/Equivalence_relation#Definition That would suggest ~ has the same precedence class as relational operators like <, >, == etc rather than arithmetic operators like +, -, *, so we should have X + Y ~ C being equivalent to (X + Y) ~ C. Relating that back to SymPy I'd expect `Z ~ Normal(0, 1)` to be a Boolean statement that could be used in some way. As a Boolean statement (X ~ Y) + Z would be meaningless because + is meaningless for Booleans so the other precedence would be more useful. The other implication of being a relational operator in Python is being usable in chaining like X < Y ~ Z. -- Oscar _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/D7SRGKXIB232J4OAZADR7R6Y4TNA6C67/ Code of Conduct: http://python.org/psf/codeofconduct/