22 May 2018

Sick or sleepy? You ruin it for everyone by forcing these kids/employees to push themselves.


Sickness

Put simply, would you prefer that one sick employee or student remains away from everyone else for the duration of their contagious illness or would you prefer that more people to get infected and productivity plummets?

In a competitive world, it's sad how people push themselves (or are pushed) to show up for work even when sick. You don't have to. Even with a chronic illness or a family member's illness, there are ways to manage it. Businesses always have a contingency plan for employee absence. It's their job to arrange for that, and not something that you have to worry about when sick.

What you should do:
Even if your illness is not contagious, stay at home and get rest. A company will never sacrifice their profitability for you, so you have no obligation to sacrifice your health for them either. I've seen this happen with multiple people. Sacrificing health for work or schooling is never worth it.


Sleep

Again, put simply: Would you prefer that people remain productive throughout the day by taking naps in-between or that they remain productive for half a day, making mistakes (which will cost you a lot in re-work) and struggling to remain awake and focus?

When you feel sleepy, you aren't supposed drink tea/coffee to shake off the feeling. You are supposed to sleep.
There's some kind of a 'laziness-related' social stigma attached to sleeping in class or in office. It's high-time we got rid of this sleep depriving culture.
Human beings are not meant to sleep only at night. We naturally have either Biphasic sleep or Polyphasic sleep. This means that when you feel like sleeping, it's perfectly ok to sleep or take a nap. You don't have to apologize to anybody. If you want to be super-human and avoid sleep, you need to take a serious look at how sleep deprivation can wreck havoc on your body.
I had a teacher who scolded students for yawning in her class. I have another teacher who feels insecure when students feel sleepy in his class. Both of them didn't seem to observe that it wasn't the fault of their teaching. All they had to do was allow the students to take a 10 minute nap.

What you should do:
If you are at a school or college, the authorities should either specifically allow for a nap break during afternoon classes, where students can rest their head on the table and take a short nap, or arrange for monitored sleep boxes.
If you work at a company, convince your bosses on how a short nap can help boost productivity without negatively affecting morale. Don't worry. There's plenty of evidence about this already. Companies can definitely introduce sleep boxes.

Sleep deprivation begins early in life and continues unless you stop it:

  • Waking through the night when the kid is born.
  • Kids sleep cycles and duration being ruined when woken up for school.
  • The horrible sleep-depriving culture of "burning the midnight oil" or waking up early during exams.
  • Eating improperly cooked or burnt food, leading to sleep loss
  • Having to wake up early to go to office.
  • Staying up to complete a project (which never gets complete).


In an ideal world, one should be allowed to sleep and wake up as per their natural sleep cycle rather than society's insensitive work cycle. When one is sick, one should be able to take rest instead of worrying about losing out in the rat race. Advice like this can only show you the way. You are the one who decides to walk the path.


You won't believe it until you measure it

If you feel you are getting enough sleep, write down how many hours of sleep you think you are getting. Then, keep a piece of paper and a pen by your bedside. Every night and morning, note down the approximate time you woke and slept.
Have two columns.
  • Column 1: Number of hours of un-interrupted sleep. 
  • Column 2: Total sleep = un-interrupted sleep + remaining sleep duration in hours.
Interrupted sleep happens when you are woken by noise at night, need to go to the toilet at midnight, are woken by discomfort in your stomach after having eaten bad food etc.

Do this experiment at least for a week or two.
I assure you; you'll be startled at how less sleep you are getting. Do let me know what your results were and I'll tell you how to improve.

19 May 2018

How to install R and R Studio on Ubuntu 16.04

The desktop installation of R is very simple if you are ok with Ubuntu's apt version.

Firstly:
You will need to have libcurl, libxml2, gtk2 and openssl installed on Ubuntu if you want to install certain packages, so also run these commands:
sudo apt-get update
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libssl-dev
sudo apt-get install libxml2-dev
sudo apt-get install libgtk2.0-dev


Method 1 (recommended):
One way that worked for me is to add the repository:
sudo add-apt-repository 'deb https://ftp.ussg.iu.edu/CRAN/bin/linux/ubuntu xenial/'
sudo apt-get update

Now you might get an error like this:
W: GPG error: https://ftp.ussg.iu.edu/CRAN/bin/linux/ubuntu xenial/ InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 51716619E084DAB9
W: The repository 'https://ftp.ussg.iu.edu/CRAN/bin/linux/ubuntu xenial/ InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: There is no public key available for the following key IDs:
51716619E084DAB9  

The solution is to add the key:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEYID
where you have to replace KEYID with the key ID shown in the error. Marked in bold three lines above this line.
Now update and install.
sudo apt-get update
sudo apt-get install r-base 
sudo apt-get install r-base-dev


Method 2: 
sudo apt-get update
sudo apt-get install r-base

Download the jpeg62 dependency from here and run dpkg to install it.
sudo dpkg -i libjpeg62_6b2-2_amd64.deb

Download R Studio from here and run dpkg to install it.
sudo dpkg -i rstudio-xenial-1.1.453-amd64.deb


Method 3:
However, if you want the latest version (advisable if you plan to install packages like arules) or you want to upgrade the version installed above, follow this:
sudo gedit /etc/apt/sources.list
Enter this line in the sources.list file (substitute the right Ubuntu version. Xenial is for Ubuntu 16.04): deb http://cran.rstudio.com/bin/linux/ubuntu xenial/
sudo apt-get update
sudo apt-get install r-base



16 May 2018

Using email like chat

Many people prefer using a messaging app for chats and email for a formal, letter-like communication. Certain people insist on always starting an email with a greeting like "Dear x", "Hi" or "Hello". It doesn't necessarily have to be that way.

If we rigorously stuck to tradition, we would be writing on cave walls and living in the jungle. There's nothing wrong with introducing change. There's nothing wrong in reducing the degree of formality to make someone feel comfortable or to make technology more cordial and usable.



If you are someone who does not like using invasive smartphone apps and are in a bit of a hurry to start/continue a conversation in a chat messenger, feel free to use email. Many modern email clients support the "email conversation" format, so it's easy to follow the conversation even if multiple people are in the conversation. It's easy to add attachments, include/exclude people, use highlighting and make use of all the other functionalities that an email offers.
Given that there are smartphone apps for email, you can even get your updates in the same way you'd get it from a messaging app.

When you are having a conversation with someone in the same way that you'd want to converse on a messaging app, go ahead and skip the formalities of email. Use email like a messaging app.
When using email for formal communication, use the standard letter-writing style and use all necessary formalities.

Let's keep technology flexible and make it comfortable for everyone. It's like how the heads of Google spoke about their choice to wear t-shirts instead of suits; they said "You don't have to wear a suit to be serious".

13 May 2018

Bitplane slicing

I was quite impressed with the person who thought of this technique. Slicing bits into planes to be able to use them to compress an image. The concept is so simple that not much explanation is needed. You'll see how it works directly from the code. Two techniques are presented here. One from Rashi Agarwal's use of mod and Angel Johnsy's use of bitget and bitset.


Once the image is sliced into bit planes, this is what you'll get:


MSB is the Most Significant Bit. LSB is the Least Significant Bit. You can choose to reconstruct the image with any of the planes which have sufficient information to represent the image. In this case I'm taking planes 7 and 6, although you could even take plane 6 and 8 or even 5 and 7.



Method 1: Using mod

clear all; close all; clc;
I = imread('moon.tif'); figure,imshow(I); title('original'); impixelinfo;
II = double(I);

%---Slice into bit planes
c0 = mod(II, 2);
c1 = mod(floor(II/2), 2);
c2 = mod(floor(II/4), 2);
c3 = mod(floor(II/8), 2);
c4 = mod(floor(II/16), 2);
c5 = mod(floor(II/32), 2);
c6 = mod(floor(II/64), 2);
c7 = mod(floor(II/128), 2);

%---display planes
figure;
sr = 2; sc = 4; si = 1;
subplot(sr, sc, si);si=si+1; imshow(c0); title('plane1. LSB');
subplot(sr, sc, si);si=si+1; imshow(c1); title('plane2');
subplot(sr, sc, si);si=si+1; imshow(c2); title('plane3');
subplot(sr, sc, si);si=si+1; imshow(c3); title('plane4');
subplot(sr, sc, si);si=si+1; imshow(c4); title('plane5');
subplot(sr, sc, si);si=si+1; imshow(c5); title('plane6');
subplot(sr, sc, si);si=si+1; imshow(c6); title('plane7');
subplot(sr, sc, si);si=si+1; imshow(c7); title('plane8. MSB');

%---restore from bit planes
figure,imshow(uint8(c7*128 + c6*64));title('restored with plane 7 and 6');
figure,imshow(uint8(c7*128 + c6*64 + c5*32 + c4*16 + c3*8 + c2*4 + c1*2 + c0));title('Fully restored');
% ri=2*(2*(2*(2*(2*(2*(2*c7+c6)+c5)+c4)+c3)+c2)+c1)+c0;%shortcut technique
% figure,imshow(uint8(ri)); title('Restored image');



Method 2: Using bitget and bitset

clear all; close all; clc;

I = imread('moon.tif'); figure, imshow(I); title('Original');
sr = 2; sc = 4; si = 1;

%---slice into planes
b1 = bitget(I,1);
b2 = bitget(I,2);
b3 = bitget(I,3);
b4 = bitget(I,4);
b5 = bitget(I,5);
b6 = bitget(I,6);
b7 = bitget(I,7);
b8 = bitget(I,8);

%---display planes
figure;
subplot(sr,sc,si);imshow(logical(b1));title('Plane1 LSB');si=si+1;
subplot(sr,sc,si);imshow(logical(b2));title('Plane2');si=si+1;
subplot(sr,sc,si);imshow(logical(b3));title('Plane3');si=si+1;
subplot(sr,sc,si);imshow(logical(b4));title('Plane4');si=si+1;
subplot(sr,sc,si);imshow(logical(b5));title('Plane5');si=si+1;
subplot(sr,sc,si);imshow(logical(b6));title('Plane6');si=si+1;
subplot(sr,sc,si);imshow(logical(b7));title('Plane7');si=si+1;
subplot(sr,sc,si);imshow(logical(b8));title('Plane8 MSB');si=si+1;

%---reconstruct using plane 7 and 8
IR = zeros(size(I));
IR = bitset(IR,7, b7);
IR = bitset(IR,8, b8);
figure, imshow(uint8(IR)); title('reconstructed with plane 7+8');

Once the planes are sliced, you can choose to take just plane 7 + plane 8 and rearrange the bits of each plane in bunches of 8 bits. Then you can convert each bunch of 8 bits to a decimal number. This is called bit plane compression

12 May 2018

Getting LaTeX working on Ubuntu 16.04

As of today, if you download the LaTeX template for IEEE conferences, you'll have to place any image named "fig1.png" in the same folder as your tex file, to be able to build the template.
You'll also have to ensure you have a few necessary packages installed on your Ubuntu OS before you can start working with the template.

To install, use the following commands:

sudo apt-get update
sudo apt-get install -y texmaker texlive-publishers texlive-science


Of course, instead of installing the texlive packages separately you could've also installed it all in one shot with the command sudo apt-get install texlive-full, but it installs a whole lot of packages, some of which you wouldn't even dream of using.

That's it. With TexMaker installed, just double click the tex file template you got, and click the "quick build" option on the TexMaker toolbar. You'll be shown a preview of the PDF.



It's not necessary to save or export the PDF, because the PDF is already created and available on the same folder that you have your TexMaker template on.

For all of you pronouncing it as Lay-Tex, the right pronunciation is shown here: https://en.wikipedia.org/wiki/LaTeX#Pronouncing_and_writing_"LaTeX".

UPDATE 2020: I've found that using LYX is far better than using TexMaker. Use LYX in tandem with JabRef.

09 May 2018

Dear Data Analytics companies. Seems like you've met your match

I came across ThoughtSpot on LinkedIn. While I felt it was silly of them to request users to sign up to see their video on how they add value, it was easy enough to find it on YouTube. If you are a Data Analytics company that's into Business Intelligence, do watch this. It'll give you a run for your money!


I've helped build a high volume cloud computing program for a company that needed to crunch Gigabytes of data at high speed. So I'm quite surprised that ThoughtSpot uses a relational database for data. Relational databases end up requiring quite a rigid schema, as compared to graph databases.
While the video does not explain how they do the data cleaning and segregation...which requires a huge amount of manual labour and no state-of-the-art AI can automatically do as of today...the video does introduce us to a very thoughtful search interface that allows the user to just type what they are searching for, and custom dashboards get created dynamically. That's where the money is!

As of today, data analytics companies spend months at a time, just to get the data organized and dashboards up and running. That incurs a very high opportunity cost for the client. Add to that an obvious high purchase cost for the analytics software, due to the highly skilled knowledge-workers that build it. Then comes the maintenance costs over the years for every little change and customization request.

The value-add that ThoughtSpot provides here, is just like what Google had provided to the world, when Yahoo Search was at it's primitive worst of requiring users to click through categories of data to find a web-page they were looking for.
It's not just clever, it's a huge money-saver and time-saver in the long-run for companies wanting to analyze their business data...which is what any company that is serious about business should be doing, pronto.

The only part I'm not yet convinced about is the amount of time that's lost in data cleaning and segregation. That's not something that can scale so easily. As for the UI and search capability ideas... brilliant!!!