Saturday, February 7, 2015

Transcription of my speech at Speakmasters on the topic SitCom

(Joke) I am really tired today. I didn't have enough coffee. I only had 7 cups. Had I have two more, I could give a great speech.

Only a few of you laughed but imagine, if I hired the entire group to laugh at my joke except a single person, that single person would join the laughter too. The group action amplifies the comedy. This is one of the working principle of modern day sitcoms. My today's speech is about sitcom.

Sitcom is shortened for situation comedy that has a progressive storyline and a lot of jokes. Its origin can be found in ancient Greece, Rome and India. In modern day sitcoms, you will hear a lot about multi-camera vs single camera. In multi-camera, there are stationary cameras on one side of the room and all the other sides of the room is filmed. It is can be considered as a theatre set where on one end you have the audience. In the single-camera, there is not necessarily one camera but the idea is that camera is not stationary. It is like movies where two characters can move freely like they can walk in the hall way. It is also the reason why laugh track is not used in Single camera.

Getting back to laugh track, how many of you think that laughter is pre-recorded? Answer is both yes and no. While most of the shows use a live audience, there are shows like How I Met Your Mother that use recorded laughter since they have so many switches to different times.

Multi-camera sitcoms have several limitations like no close up shot of the actors and also, enclosed set like living room. But they are good money and better rating than single camera sitcom.

Writing SitComs is very  productive. Each episode usually requires a 20-30 pages manuscript. But the writer's salary is very high. Here are a few tips to write a successful SitCom:
1. Pick a theme that has been used before. Most of the successful shows are a remix of the old shows
2. Write the story first and add jokes later. Story will act as a path that your show will follow
3. Lead character can be a genius in his work but should be insecure about him/her when it comes to other aspects of life
4. Make your characters loveable to the audience. One easy trick is to hire (or describe them in the writing) really attractive people.

Friday, July 4, 2014

Frequently asked questions regarding higher study in Canada

Q. Is it must to give IELTS/TOEFL exam to get admission in Canada?
Ans: Usually, you need to give IELTS/TOEFL to study in Canada. But there are exceptions, too. For example, one of my friends came to Canada for her masters. For her, IELTS requirement was waived as her undergrad medium of instruction was English. Note that not all Canadian universities waive it but some do. Check with individual university's rule. Sometimes, even if it is not mentioned in the university's rule, you can pursue your case by reminding the graduate administrator that your undergrad was taught in English. To start with, consider University of Alberta, University of Canada as I have seen Bangladeshi students got admission at these schools without IELTS/TOEFL.

Q. How to write emails to Professors/
Ans: In the email, you need to talk about one/two topic that you want to work on. Pick two/three economics topics from the professor's website. Write one paragraph on each topic. In the writing, you will describe what the problem is and what needs to be done. For example, poor people can take loan from microcredit banks. It certainly helps them to start their own business. Due to the high risk, the banks impose high interest rate on the clients. It often makes the clients suffer and brings negative media publication. I want to investigate how this problem can be mitigated. It requires understanding each party's need and expectation.

This is just an example. You need to select topics and write on them. Use your own language. If necessary, take help from someone who is knowledgeable about the area. Just carefully select topics so that they match professor's interest.

Q. How to search for universities?
Ans: Visit the department's webpage (e.g., cpsc.ucalgary.ca) as well as the graduate admission page (e.g., grads.ucalgary.ca). Prepare a word document where list each university along with their requirements for
GPA: IELTS: GRE/GMAT: Tuition: Course-condition, number of reference letter. It will speed up your search process. It works as a progress bar.
Go through all the professors personal website. Know their research interest. Use google a lot if you are not familiar, take a friend's help who knows google very well.

Q. If someone is living in Canada already on a work permit, can he/she study?
Ans: I don't know the right answer. But here is a thought. (S)He needs to get admission from a college. Then they can apply for the study permit with the admission confirmation as a supporting document. Then it would be a decision of the Canadian immigration. It is better to check the exact rules from cic.gc.ca 

Wednesday, April 25, 2012

Latex documents in Lyx with ACM SIG template class

Setup the stage:
           Install the latest version of MikTEX
           Install Lyx

Basics on Lyx and Latex:
           To get started, watch these videos from 1-4 

           See this Screencast on How to add images

To use ACM SIG template class, follow the instructions

Note that the file is initially read only. So you need to save it to edit. When you press view pdf, it might give error message regarding image size. Just replace the images with any existing image from HDD.

Scale a table:
In order to scale a table to fit the size of the document, use this starting file. In your own document, you need to add packages in order run the instructions that you see in the starting file. You can add packages in the following manner.

How to add packages into the preamble of a document:


Friday, April 13, 2012

Copy by Value Copy by Pointer


In Python, variables are treated like objects. In fact, data structures are classes and a specific data structure variable is an object of that class. Consider lists in Python. When you create a list variable, it is treated like an object of a class. The contents of the variable are not a set of values rather it is a pointer to the memory spaces that contain those values.
Therefore, when the variable is copied or assigned to another variable, the pointer is copied. The assignment will not duplicate values in the memory but it will duplicate the pointer and finally, there will two pointers pointing to the same memory spaces. As a result, if the contents are changed using the second variable, the contents for the first variable also get changed.

For example
>>> a=[23,45,66]
>>> b=a
>>> b[0]=90
>>> a
[90, 45, 66]
>>>

This is called copy by pointer.

Another way to explain it is this. For example, I have a document containing some text. After opening the document with MS Word, I can create multiple windows and all will show the content of the document. These are all pointers to the same content. If I change content in one of these, contents in the rest will be changed too.

Now if the contents are selected using ctrl+a and pasted to a new file in Notepad, Wordpad or even MS Word using ctrl+v, then the contents are duplicated instead of pointer. Now there will be two pointers pointing to different memory spaces. Changing contents using one will not affect other.

This is called copy by value. To copy the contents of a list, use the instruction, b=a[:] instead of b=a.


Saturday, December 10, 2011

Finding the gem (Programming problem)

There is a 5by5 grid where each cell contains a gem. Each gem has a name. The grid should contain only one Kohinoor. Find the Kohinoor. At each step of the search, print the cell name where you are searching. As soon as you find the Kohinoor, stop searching and print Kohinoor is found.

Friday, December 2, 2011

Watching Carrer IQ watching us

Carrer IQ is a software that is shipped with many smartphones like iPhone 4 and Android phones. It provides feedback to the phone carrier about its network and subscribers.
A developer named Trevor Eckhart who had access to a unmodified version of Carrier IQ discovered that Carrier IQ's software logs all the keystrokes a user make on their device. The software even logs interactions over secure connection (https). Trevor released a video explaining how the surveillance takes place. Carrier IQ tried to silence him by threatening with legal actions.



If you are curious about your phone having Carrier IQ, try this android app to find out.

Saturday, November 26, 2011

Programming problem (Naive)

A square is given in Cartesian coordinate system. The coordinates of only three points of the square are given. Assume that coordinates have only integer values. Find the forth coordinates.

Saturday, October 22, 2011

Multiplication of two very large matrices: python program

Given program reads Matrix A and B from these locations:

loc1="C:\Python32\matrixA.csv"
loc2="C:\Python32\matrixB.csv"

and writes the product matrix in this location:

loc2write="C:\Python32\matrixF.csv"

If locations are different in your case, change these variables in the source code.

Files:
Python code
Sample Matrix A
Sample Matrix B

Tuesday, October 18, 2011

K- Means clustering

Algorithm:
Suppose you have a data set of {d1, d2, ..., dn}

Step1: choose random points from the data set as k centers {c1,c2,...,ck}
Step2: Assign all the points of the data sets into one of the k centers
Step3: Recalculate all the centers {c1,c2,...,ck} as the mean of all the points assigned to it.
Step4: Repeat step 2 and 3 until there is no change in the mean (or centers)

Example:

Problem: Cluster the following eight points (with (x, y) representing locations) into three clusters A1(2, 10) A2(2, 5) A3(8, 4) A4(5, 8) A5(7, 5) A6(6, 4) A7(1, 2) A8(4, 9). Initial cluster centers are: A1(2, 10), A4(5, 8) and A7(1, 2). The distance function between two points a=(x1, y1) and b=(x2, y2) is defined as: ρ(a, b) = |x2 – x1| + |y2 – y1| .
Use k-means algorithm to find the three cluster centers after the second iteration.


Solution:

Iteration 1
(2, 10) (5, 8) (1, 2)
Point Dist Mean 1 Dist Mean 2 Dist Mean 3 Cluster
A1 (2, 10)
A2 (2, 5)
A3 (8, 4)
A4 (5, 8)
A5 (7, 5)
A6 (6, 4)
A7 (1, 2)
A8 (4, 9)

First we list all points in the first column of the table above. The initial cluster centers – means, are (2, 10), (5, 8) and (1, 2) - chosen randomly. Next, we will calculate the distance from the first point (2, 10) to each of the three means, by using the distance function:



point mean1
x1, y1 x2, y2
(2, 10) (2, 10)

ρ(a, b) = |x2 – x1| + |y2 – y1|

ρ(point, mean1) = |x2 – x1| + |y2 – y1|
= |2 – 2| + |10 – 10|
= 0 + 0
= 0




point mean2
x1, y1 x2, y2
(2, 10) (5, 8)

ρ(a, b) = |x2 – x1| + |y2 – y1|

ρ(point, mean2) = |x2 – x1| + |y2 – y1|
= |5 – 2| + |8 – 10|
= 3 + 2
= 5




point mean3
x1, y1 x2, y2
(2, 10) (1, 2)

ρ(a, b) = |x2 – x1| + |y2 – y1|

ρ(point, mean2) = |x2 – x1| + |y2 – y1|
= |1 – 2| + |2 – 10|
= 1 + 8
= 9



So, we fill in these values in the table:

(2, 10) (5, 8) (1, 2)
Point Dist Mean 1 Dist Mean 2 Dist Mean 3 Cluster
A1 (2, 10)----0-------5------------9---------(1)
A2 (2, 5)
A3 (8, 4)
A4 (5, 8)
A5 (7, 5)
A6 (6, 4)
A7 (1, 2)
A8 (4, 9)


So, which cluster should the point (2, 10) be placed in? The one, where the point has the shortest distance to the mean – that is mean 1 (cluster 1), since the distance is 0.


Cluster 1 Cluster 2 Cluster 3
(2, 10)


So, we go to the second point (2, 5) and we will calculate the distance to each of the three means, by using the distance function:


point mean1
x1, y1 x2, y2
(2, 5) (2, 10)

ρ(a, b) = |x2 – x1| + |y2 – y1|

ρ(point, mean1) = |x2 – x1| + |y2 – y1|
= |2 – 2| + |10 – 5|
= 0 + 5
= 5




point mean2
x1, y1 x2, y2
(2, 5) (5, 8)

ρ(a, b) = |x2 – x1| + |y2 – y1|

ρ(point, mean2) = |x2 – x1| + |y2 – y1|
= |5 – 2| + |8 – 5|
= 3 + 3
= 6




point mean3
x1, y1 x2, y2
(2, 5) (1, 2)

ρ(a, b) = |x2 – x1| + |y2 – y1|

ρ(point, mean2) = |x2 – x1| + |y2 – y1|
= |1 – 2| + |2 – 5|
= 1 + 3
= 4
So, we fill in these values in the table:

Iteration 1
(2, 10) (5, 8) (1, 2)
Point Dist Mean 1 Dist Mean 2 Dist Mean 3 Cluster
A1 (2, 10)----0----------5----------9----------(1)
A2 (2, 5) ----5----------6----------4-----------(3)
A3 (8, 4)
A4 (5, 8)
A5 (7, 5)
A6 (6, 4)
A7 (1, 2)
A8 (4, 9)


So, which cluster should the point (2, 5) be placed in? The one, where the point has the shortest distance to the mean – that is mean 3 (cluster 3), since the distance is 0.

Cluster 1 Cluster 2 Cluster 3
(2, 10) (2, 5)




Analogically, we fill in the rest of the table, and place each point in one of the clusters:

Iteration 1
(2, 10) (5, 8) (1, 2)
Point Dist Mean 1 Dist Mean 2 Dist Mean 3 Cluster
A1 (2, 10)----0----------5----------9----------(1)
A2 (2, 5) ----5----------6----------4----------(3)
A3 (8, 4) ----12----------7----------9----------(2)
A4 (5, 8) ----5----------0----------10----------(2)
A5 (7, 5) ----10----------5----------9----------(2)
A6 (6, 4) ----10----------5----------7----------(2)
A7 (1, 2) ----9----------10----------0----------(3)
A8 (4, 9) ----3----------2----------10----------(2)

Cluster 1 Cluster 2 Cluster 3
(2, 10)-(8, 4)-(2, 5)
          -(5, 8)-(1, 2)
          -(7, 5)-
          -(6, 4)-
          -(4, 9)-
Next, we need to re-compute the new cluster centers (means). We do so, by taking the mean of all points in each cluster.

For Cluster 1, we only have one point A1(2, 10), which was the old mean, so the cluster center remains the same.

For Cluster 2, we have ( (8+5+7+6+4)/5, (4+8+5+4+9)/5 ) = (6, 6)

For Cluster 3, we have ( (2+1)/2, (5+2)/2 ) = (1.5, 3.5)



The initial cluster centers are shown in red dot. The new cluster centers are shown in red x.

That was Iteration1 (epoch1). Next, we go to Iteration2 (epoch2), Iteration3, and so on until the means do not change anymore.
In Iteration2, we basically repeat the process from Iteration1 this time using the new means we computed.

Courtesy: The example is taken from the following website
http://faculty.uscupstate.edu/atzacheva/Teaching.html

Wednesday, October 12, 2011

Quick sort visual demonstration



Quick sort pseudocode: [wikipedia]

function quicksort(array, 'left', 'right')
{
// If the list has 2 or more items
if 'left' < 'right'

// See "Choice of pivot" section below for possible choices
choose any 'pivotIndex' such that 'left' ≤ 'pivotIndex' ≤ 'right'

// Get lists of bigger and smaller items and final position of pivot
'pivotNewIndex' := partition(array, 'left', 'right', 'pivotIndex')

// Recursively sort elements smaller than the pivot
quicksort(array, 'left', 'pivotNewIndex' - 1)

// Recursively sort elements at least as big as the pivot
quicksort(array, 'pivotNewIndex' + 1, 'right')
}

//Pseudo code for partition is not given here.

Friday, September 4, 2009

Transfer files via Remote Desktop Connection

These instructions are written following Windows Vista. I guess they would be very similar in Windows XP too. Go through the following steps.
  1. Run the Remote Desktop Connection.
  2. Click Options and go to the Local Resources tab.
  3. Click the button 'More' and a new dialog box will apear.
  4. Check these options - Smart card and Drives. Press OK to close the dialog box.
  5. Now go back to the General tab and save the settings.
Now you are good to go. Connect to the remote machine and copy files and paste onto the local machine.

Sunday, June 8, 2008

How to recover text from any Damaged MS Word file

Note When you change the Files of type box to Recover Text from any File in the Open dialog box (on the File menu, click Open), Word will 'remember' this setting and will use it the next time you open a document. To avoid this problem, reset the Files of type box back to Word Document (*.doc) after you have completed recovering your document.

To use the converter on a Word file, follow these steps:
1.On the File menu, click Open, and then click the document.
2.In the List Files Of Type box, click Recover Text from Any File, and then click Open.
To use the converter on any non-Word file in Microsoft Word 98 for Mac or in Microsoft Word 2001 for Mac, follow these steps:
1.On the Tools menu, click Preferences.
2.Click the General tab.
3.Click to select the Confirm conversion at Open check box, and then click OK.
4.On the File menu, click Open.
5.Click the file you want to recover, and then click OK.

The Convert File dialog box appears.
6.In the Convert File dialog box, click the Recover Text from Any File converter, and then click OK.
To use the converter on any non-Word file in Microsoft Office XP for Mac or in Microsoft Office 2004 for Mac, follow these steps:
1.On the File menu, click Preferences.
2.Click the General tab.
3.Click to select the Confirm conversion at Open check box, and then click OK.
4.On the File menu, click Open.
5.Click the file you want to recover, and then click OK. The Convert File dialog box appears.
6.In the Convert File dialog box, click the Recover Text from Any File converter, and then click OK.
Word will convert the damaged document and recover any text from the document.

What does the "...Attempt recovery now" message mean?

When Word detects that there is a damaged document to be recovered, Word displays the following message:
Word encountered file corruption while opening .
Part of this document may be recoverable. Attempt recovery now?
This message is displayed when an automatically recovered file is present but Word is unable to recover it. When you start Word, Word finds the document and asks if you want Word to try to recover it.

If you click No, Word will not attempt to recover the document, and the document will be permanently lost.

If you click Yes, Word will attempt to recover the document. If Word is successful in recovering the file, save the document as a normal Word document.


"Recover Text from Any File" doesn't appear in the Convert File dialog box

The Recover Text from Any File converter is not installed. You will need to run Office Custom Install to install this converter.
1.On the Microsoft Office CD-ROM, double-click the Office Custom Install folder.
2.Double-click the Microsoft Office Installer icon.
3.Click Custom Install in the list at the top of the window.
4.Click the triangle tab next to Converters and Filters.
5.Click the triangle tab next to Text Converters.
6.Click to select the Recover Text Converter check box, and then click Install.
The Recover Text Converter is installed in the following location:
Microsoft Office 98:Shared Applications:Text Converters