theory

The recognizing power of “modern” regexes

妖精的绣舞 提交于 2019-11-25 23:36:45
问题 What class of languages do real modern regexes actually recognise? Whenever there is an unbounded length capturing group with a back-reference (e.g. (.*)_\\1 ) a regex is now matching a non-regular language. But this, on its own, isn\'t enough to match something like S ::= \'(\' S \')\' | ε — the context-free language of matching pairs of parens. Recursive regexes (which are new to me, but I am assured exist in Perl and PCRE) appear to recognize at least most CFLs. Has anyone done or read any

Big-O for Eight Year Olds? [duplicate]

给你一囗甜甜゛ 提交于 2019-11-25 23:02:40
This question already has an answer here: What is a plain English explanation of “Big O” notation? 39 answers I'm asking more about what this means to my code. I understand the concepts mathematically, I just have a hard time wrapping my head around what they mean conceptually. For example, if one were to perform an O(1) operation on a data structure, I understand that the number of operations it has to perform won't grow because there are more items. And an O(n) operation would mean that you would perform a set of operations on each element. Could somebody fill in the blanks here? Like what

Way to go from recursion to iteration

£可爱£侵袭症+ 提交于 2019-11-25 22:18:46
问题 I\'ve used recursion quite a lot on my many years of programming to solve simple problems, but I\'m fully aware that sometimes you need iteration due to memory/speed problems. So, sometime in the very far past I went to try and find if there existed any \"pattern\" or text-book way of transforming a common recursion approach to iteration and found nothing. Or at least nothing that I can remember it would help. Are there general rules? Is there a \"pattern\"? 回答1: Usually, I replace a

Probability Theory and Mathematical Statistics

耗尽温柔 提交于 2019-11-25 22:02:03
概率论 事件的差 \(P(B-A) = P(B)-P(AB)\) 古典概型 可能性相同 个数有限 独立性 乘法公式 \(P(AB) = P(A)P(B|A)\) 推广: \(P(A_1A_2A_3...A_n) = P(A_1)P(A_2|A_1)...P(A_n|A_1A_2...A_{n-1})\) 独立性 若 \(P(A_1A_2A_3...A_n) = P(A_1)P(A_2)...P(A_n)\) 则称 \(A_1,A_2,...,A_n\) 相互独立 独立性相当于:内在没有联系,它们不会影响彼此的发生 推论: 性质1:$P(B) = P(B|A) $ 性质2:这些事情取反也是相互独立,很好证明 全概率公式和贝叶斯公式 全概率公式 \(P(B) = \sum_{i=1}^{n} {P(A_i)P(B|A_i)}\) "全"概率公式, \(P(B)\) 被分解成多部份之和 贝叶斯公式 \(P(A_i |B) = \frac{P(A_iB)}{P(B)}\) \(P(B) = \sum_{i=1}^{n} {P(A_i)P(B|A_i)}\) \(P(A_i |B) = \frac{P(A_iB)}{\sum_{i=1}^{n} {P(A_i)P(B|A_i)}}\) 我们要知道一个概念: \(P(A_i)\) 叫做”先验概率“; 随机变量 离散型随机变量 0-1分布 又名

Storing Images in DB - Yea or Nay?

情到浓时终转凉″ 提交于 2019-11-25 21:32:15
问题 So I\'m using an app that stores images heavily in the DB. What\'s your outlook on this? I\'m more of a type to store the location in the filesystem, than store it directly in the DB. What do you think are the pros/cons? 回答1: I'm in charge of some applications that manage many TB of images. We've found that storing file paths in the database to be best. There are a couple of issues: database storage is usually more expensive than file system storage you can super-accelerate file system access