Friday, December 23, 2016

Trials until first success

This is a famous problem in 50 challenging problems in probability. The question is On the average, how many times must a die be thrown until one gets a 6 ? Let p be the probability of getting a 6. Now we can get this at first trial with probability $p$, on 2nd trial with probability $(1-p)p$, or on 3 trial with $(1-p)^2p$ and so on. The expected value is $N= 1p+2(1-p)p+3(1-p)^2p+4(1-p)^3p+\cdots$ $\Rightarrow N(1-p)=1(1-p)p+2(1-p)^2p+3(1-p)^3p+4(1-p)^4p+\cdots$ Subtracting we get $\Rightarrow N(1-1+p)=p+(1-p)p+(1-p)^2p+(1-p)^3p+\cdots$ $\Rightarrow Np= p((1-p)+(1-p)^2+(1-p)^3+(1-p)^4+\cdots$ $\Rightarrow N= \frac{1}{1-(1-p)}$ $\Rightarrow N= \frac{1}{p}$ Thus if the probability of success is $p$. On an average it will take $\frac{1}{p}$ number of trials for the first success.

Labels: ,

Saturday, December 10, 2016

Factitious, Facetious and Circumspect

Made up in the sense of contrived; a sham, fake or phony
The CIA agent hid his message inside the hollow factitious rock by the bridge; his handler would pick up the message a few hours later.
My dad's factitious smile didn't fool anyone; he was definitely not happy to see our cousins show up once again unannounced.

Facetious

Cautious, Prudent
Circumspect is a combination of circum ("around") and spect ("look"). To remember this word, think of a cautious person "looking around" before he or she acts.

Factotum and Procrustean

Two new words Factotum: A factotum is someone hired to do a variety of jobs, someone who has many responsibilities, a jack of all trade.
Example: Tessa, the office factotum, does the billing, answers the phones, helps out in the PR department, and even knows how to cook a mean blueberry scone- she's indispensable. Andrea in my school is a factotum. "fac" is a latin word for facio, meaning to make or do. "totum" means all. Therefore factotum is someone who does all. Other example: The intendant became the king's factotum. Gallop off to Texas, he said to the factotum who appeared at his call.

Procrustean: Procustes was a mythical bandit of Attica who would waylay hapless travelers and attempt to fit them to his iron bed. If travelers were too long for the bed, he'd cut off their feet. If they were too short, he'd stretch them out. A procrustean bed has come to mean an arbitrary standard to which something is forced to confirm.

Even though student's poem unanimously won all county writing contest, the procrustean English teacher gave her an F for failing to do the i in her name.
I was shocked by their procrustean attitude towards completing the syllabus. I think a teacher is a best judge of determining the pace of the class.

Sunday, December 04, 2016

Locks in a grid problem

This is a simulation to an interesting problem about a lock. Which has n key slots. These slots are either vertical or horizontal. To open the lock these slots have to be in a particular configuration. If we put the key in one slot and turn its orientation all the other slots in that particular row and column change their configuration. Is it possible to open this lock for a particular configuration of 16 slots ? If yes then how ?
       

"""The purpose of this is to simulate the problem of locks
where when you turn on the key in the grid all the other
keys in the same row and column also turn. I represent this
by 0 and 1
One can experiment and learn that if the grid is even by even
then we can change any particular bit by"""
n = 4
a=[]
sum = 0
# It prints the whole Grid of Locks
def printMatrix(val):
for i in range(n):
print(val[i])

# It flips the entries from 0 to 1 and 1 to 0
def flip(val):
if val == 0:
return 1
return 0

# It changes the entries in a given row and column
def ChangeRowChangeColumn(a,i,j):
a[i][j]=flip(a[i][j])
for k in range(n):
a[i][k]=flip(a[i][k])
for k in range(n):
a[k][j]=flip(a[k][j])

for i in range(1,n+1):
b=[]
for j in range(1,n+1):
b.append(1)
c = b[:]
sum= sum+n
a.append(c)
del b[:]
printMatrix(a)
flag=1
while(flag == 1):
row=int(input("Enter what row you want to change ?"))
col=int(input("Enter what column you want to change?"))
ChangeRowChangeColumn(a,row,col)
printMatrix(a)
flag = int(input("Enter 0 or 1 to continue"))




Labels: ,

Friday, December 02, 2016

Bonferroni Inequality and how to think about it

Bonferroni Inequality provides a lower bound for intersection of sets in terms of the individual probability of sets. For $2$ sets. It says that $P(A_1 \cap A_2) \ge P(A_1)+P(A_2)-1$ for two sets $P(A_1 \cap A_2 \cdots \cap A_n) \ge P(A_1)+P(A_2)+\cdots+P(A_n)-n+1$ for n sets Main Idea: The union of sets is always smaller than the sum of the individual sets. You can basically take this as an axiom. We start with $P(A \cup B)= P(A)+P(B)-P(A \cap B)$ $\Rightarrow P(A \cap B)= P(A)+P(B)-P(A \cup B)$ as $P(A \cup B) \le 1$ $\Rightarrow P(A \cap B) \ge P(A)+P(B)-1$ This can also be written as $P(A \cap B) \ge P(A)+P(B)-2+1$ Let's generalize it for $n$ sets. Notice that $P(A_1 \cap A_2 \cap \ldots \cap A_n)=P((A_1^c \cup A_2^c \cup\ldots \cup A_n^c)^c) = 1-P(A_1^c \cup A_2^c \cup \cdots \cup A_n^c)$ $\Rightarrow 1-P(A_1^c \cup A_2^c \cup \cdots \cup A_n^c) =P(A_1 \cap A_2 \cap \ldots \cap A_n)$ $\Rightarrow P(A_1^c \cup A_2^c \cup \cdots \cup A_n^c) =1-P(A_1 \cap A_2 \cap \ldots \cap A_n)$ Lets start with the idea that probability of union of sets is always smaller than the sum of probabilities of individual sets. $\Rightarrow P(A_1^c \cup A_2^c \cup \ldots \cup A_n^c) \le P(A_1^c)+P(A_2^c)+\ldots+P(A_n^c)$ $\Rightarrow 1-P(A_1 \cap A_2 \ldots \cap A_n) \le 1-P(A_1)+1-P(A_2)+\ldots+1-P(A_n)$ $\Rightarrow 1-P(A_1 \cap A_2 \ldots \cap A_n) \le n-P(A_1)-P(A_2)-\ldots -P(A_n)$ $\Rightarrow P(A_1)+P(A_2)+\ldots+P(A_n)\le P(A_1 \cap A_2 \ldots \cap A_n)-1+n$ $\Rightarrow P(A_1)+P(A_2)+\ldots+P(A_n)-n+1\le P(A_1 \cap A_2 \ldots \cap A_n)$ $\Rightarrow P(A_1 \cap A_2 \ldots \cap A_n)\ge P(A_1)+P(A_2)+\ldots+P(A_n)-n+1$

Labels: ,