Live data from Hacker News

Equations True Computer Science Geeks Should (at Least Pretend to) Know

elegantcoding.com

11–20 of 100 posts

Re: Equations True Computer Science Geeks Should (at Least Pretend to) Know

#13
post #9

I really wish my brain didn't gloss over the first time I see a math symbol. All of this stuff seems intriguing but it's almost as if I'm hardwired to translate all those symbols into mush. I'd be much more interested in seeing the equivalent code snippets these ideas express.

For several of the equations presented, there's not really a "code equivalent". And for most of the others, presenting it in code form would make it much more verbose and complex than it needs to be. In a way, it's already written in code – it's just been written by mathematicians :)

It can be a bit daunting at first, but I find mathematical concepts and notation extremely useful tools for programmers, especially when designing algorithms. It allows you to express powerful, abstract ideas in a few lines whereas the same reasoning in pseudo-code would take much more time and effort.

I'm glad my undergraduate program was heavy on the math (although I hated it at the time)– it made graduate CS courses easier to understand, and programming easier for me in the long term. I actually miss my pure math courses now.

Re: Equations True Computer Science Geeks Should (at Least Pretend to) Know

#14
More fundamental than Bayes's theorem is the probabilistic counterpart of modus ponens: P(A/\B) = P(B|A) P(A). This corresponds to the logical rule of inference A, A->B |- A/\B. Note that modus ponens is usually stated in the form A, A->B |- B. But this throws away useful information, namely that proposition A is true, so it's a weaker form.

Bayes's theorem is a direct consequence of this axiom and the commutativity of conjunction.

Re: Equations True Computer Science Geeks Should (at Least Pretend to) Know

#15
post #9

I really wish my brain didn't gloss over the first time I see a math symbol. All of this stuff seems intriguing but it's almost as if I'm hardwired to translate all those symbols into mush. I'd be much more interested in seeing the equivalent code snippets these ideas express.

I've found http://en.wikipedia.org/wiki/Table_of_mathematical_symbols to be helpful when deciphering formulas. It's hard to remember what all the notation means sometimes.

Re: Equations True Computer Science Geeks Should (at Least Pretend to) Know

#16

I would take issue with the pumping lemma for regular languages here. The formal statement of the lemma is outrageously complicated, which makes it really difficult to understand and use. The only good justification I’ve heard for including this result in a CS curriculum is that it’s a good warm-up for the pumping lemma for context-free languages, which is more useful. If you actually ever find yourself needing to sh…

>there are non-regular languages that pass the pumping lemma test

Can you give an example of that? You may be right, but I'm having a hard time coming up with a language that is not regular but fulfils the pumping lemma.

Re: Equations True Computer Science Geeks Should (at Least Pretend to) Know

#17

I would take issue with the pumping lemma for regular languages here. The formal statement of the lemma is outrageously complicated, which makes it really difficult to understand and use. The only good justification I’ve heard for including this result in a CS curriculum is that it’s a good warm-up for the pumping lemma for context-free languages, which is more useful. If you actually ever find yourself needing to sh…

>there are non-regular languages that pass the pumping lemma test Can you give an example of that? You may be right, but I'm having a hard time coming up with a language that is not regular but fulfils the pumping lemma.

Sure, there’s an example in the Wikipedia article linked from the footnote in my comment above: the language consisting of all strings over the alphabet {0,1,2,3} with a substring of length 3 including a duplicate character, as well as all strings over this alphabet where precisely 1/7 of the string's characters are 3's.

As you can see, this example is a little complicated – and I don’t know a simpler one, so I’m not surprised you struggled to just come up with an example off the top of your head.

Re: Equations True Computer Science Geeks Should (at Least Pretend to) Know

#18

More fundamental than Bayes's theorem is the probabilistic counterpart of modus ponens: P(A/\B) = P(B|A) P(A). This corresponds to the logical rule of inference A, A->B |- A/\B. Note that modus ponens is usually stated in the form A, A->B |- B. But this throws away useful information, namely that proposition A is true, so it's a weaker form. Bayes's theorem is a direct consequence of this axiom and the commutativity…

[deleted]

Re: Equations True Computer Science Geeks Should (at Least Pretend to) Know

#19

More fundamental than Bayes's theorem is the probabilistic counterpart of modus ponens: P(A/\B) = P(B|A) P(A). This corresponds to the logical rule of inference A, A->B |- A/\B. Note that modus ponens is usually stated in the form A, A->B |- B. But this throws away useful information, namely that proposition A is true, so it's a weaker form. Bayes's theorem is a direct consequence of this axiom and the commutativity…

In other words, modus ponens is: P(A=true)=1, P(B=true|A=true)=1 |- P(B=true) = 1

Let P'(A) be the distribution on A when we know nothing about B (in a world with only A and B). Plausible reasoning is possible through Bayes/joint-conditional probability rule and yields: P(B=true|A=true)=1, P(B=true)=1 |- P(A=true) > P'(A=true) where logic alone can't conclude (A->B, B |- ?) Also: P(B=true|A=true)=1, P(A=false)=1 |- P(B=true) < P'(B=true)

Re: Equations True Computer Science Geeks Should (at Least Pretend to) Know

#20
post #3

It'd be nice if the author actually stated why these algorithms are important to know. Give a use case, rather than "this comes up sometimes."

Agreed, this article was a very poor read from the perspective of a programmer (yours truly) having a working familiarity with only two or three of these concepts.

Given the article's slapdash, loosely-coherent English and tendency to pad out each equation's section with references to even more equations--and not explanation of usefulness--I wish I hadn't tried to read it, for it was very frustrating. I suppose the article might provoke interesting discussion among the mathy set, the same way that a list of "top patterns" might start a discussion among OO fans.

Post reply on HN