Category Archives: Blogs (博客)

Root-Mean-Square Deviation (Error) – RMS, RMSD, and RMSE

The root-mean-square deviation (or error) characterizes the differences between two sets of data. Its name literally explains its definition: The difference is squared and then averaged, then the final result of the square root of the average.

For example, assume we have two sets of data:

Set A – x: 1, 2, 3 (red)

Set A – y: 1, 1, 2 (red)

Set B – x: 1, 2, 3 (blue)

Set B – y: 2, 3, 1 (blue)

Because the x coordinates of these two sets are identical, the RMSD can be directly calculated from the differences between each corresponding y values, as shown in the figure.

RMSD = sqrt( (e1^2+e2^2+e3^2) / 3 )

Therefore the sign of e1 (2, or 3) doesn’t matter, and only its amplitude affects the RMSD.

However, in real numerical calculations, the x coordinates of the two data sets are often not the same. In this case, we can specify one data set as the reference and the other one as the sample. The sample data will then be projected into the reference data and find the corresponding deviations.

For example, if we change the last x coor
dinate of set B to be 3.5 and select set A as the reference, the RMSD is calculated as illustrated in the figure. This time, the value of e3 is 3 instead of 2.

If the projection happens within two data points of the reference, then its value is a interpretation. If it is located outside the x range of the reference, its value is obtained through extrapolation (like the example).

Note that if we select set B to be the reference, the result will be different, as shown in the figure. Obviously, this time the value of e3 is much smaller than the case when set A is reference.

Here we give a Matlab program to calculate the RMSD. It requires the user to input two data sets and specify which data set is the reference.

link (works with Matlab and GNU Octave)


Install TeamViewer12 on Fedora 25

I use teamviewer to manage my home computer while I am at work. So I tried to install teamviewer 12 on Fedora 25. The good thing is, teamviewer has an officially supported software for Fedora on their website and the installation is very straightforward. But, there is still a bad news: it cannot connect to the teamviewer server. After some googling, I figured out it is not compatible with some default setting of Fedora 25, which I don’t really want to change. So I following the instructions on the teamviewer community. [1] But the instructions are vague and I want to clarify them here.

They suggested, we can use the 3rd option on Teamviewer website, which is for other Linux distributions, a tar file that is not officially supported, on Fedora 25. So I downloaded the tar file and extract it. Then I need to figure out how to use it. I basically gives two options: install and without installation. I went for the 2nd one. The first thing to do is cd into the extracted directory, and then execute ./tv-setup, it will give you several options, I suggest to do a library check first, which is

./tv-setup checklibs

Depending on your situation, you may need some libraries. Usually they will suggest the command to install those missing libraries. You basic need to copy than and paste the commad after sudo.

After installing the missing libraries, do the check again and you should see
Analyzing dependencies (64 bit)…

All 64 bit dependencies seem to be satisfied!

Analyzing dependencies (32 bit)…

All 32 bit dependencies seem to be satisfied!

Now, if you run ./teamviewer, it will launch the program and I didn’t find any differences with the one installed on Mac or PC. Enjoy.

Fedora on Mac: How to input tilde

I recently installed Fedora 25 on my 2015 Macbook Pro (13 inch). The first problem I got is how to input ` and ~. By default, the system gives > and < when I press or shift+press the button right below the esc button on the native keyboard. I searched online and found a very helpful post on this. [1]

However, the instrument given by that post doesn’t work for Fedora 25. I strictly follow the instruction to add the following lines to /etc/rc.d/rc.local


echo 0 | sudo tee /sys/module/hid_apple/parameters/iso_layout

And change its permission using sudo chmod 0755 /etc/rc.d/rc.local

After rebooting, I still cannot input ` or ~. Note that, if I manually run this script, it can actually do its work and enable the input of ` and ~. It just does not run autonomously after startup.

I wanted to see what is preventing it, so I use the command

systemctl status rc-local

and I got a summary saying that rc.local failed because line 2, sudo, command not found. Interesting. I googled it and someone suggested that the environment at startup is different with the one after startup, so some commands may not be available. And I don’t need to use sudo in rc.local. Thus, I deleted the sudo, and kept everything else untouched. Save, reboot. Bingo, it works autonomously.

That is why I write this post to share this. It did take me more than one hour to figure this out. And I really appreciate there are so many people share their experience and suggestions online.



Tween 20

What is Tween 20?

Tween 20 is a registered name by Croda Americas. Its academic name is polysorbate 20. It is mainly used as one kind of nonionic surfactant, thanks to its stability and relative nontoxicity.


How does Tween 20 work?

As a surfactant, its molecule has a hydrophilic head a hydrophobic tail. When we want to dissolve something that is not easily dissoluble in water, Tween 20 can be added to help this dissolution process.


Where is Tween 20 applied?

Many areas, mostly in biology, medicine, microfluidics, food industry, etc. For one example, we often need to dissolve some microbeads into water to test a microfluidic channel. Most beads are not dissoluable by their natures, so Tween 20 is added to make sure the beads will be distributed uniformly in water.

Shear Force

Shear force is name used to refer to some forces in a certain scenarios. A force is a force. There is no difference in the nature between the all kinds of varying forces. We human beings just like to give specific names to the same thing in different places.

As one example, if a square (let’s constraint ourselves to the 2D plane) experiences two opposite forces, which are applied to its center, the square is compressed and has a net force is the two forces doesn’t equal to each other (high school knowledge). If we shift the two forces to the top and bottom boundaries of the square, the two forces will rotate the square if it is free to rotate because a torque is generated. But if the square cannot rotate, it will deform and these two forces are called the shear forces.

Shear forces are often responsible for the crack and tear of materials. It is not hard to image in the previous example that the square in the 2nd scenario is more likely to break. In academia (or courses for students), the shear force is not very common. But people dealing with cantilever beams or mechanics may encounter shear forces quite often. For example, when a beam is supported by its two endpoints and there is a point force applied at the center, there will be two reactive forces to balance the applied force. When the beam has reached its equilibrium, any section of it should be balanced. So if we only look at left portion of it, there needs to be a shear force on the right boundary to balance the upward-pointing force on its left end.

Shear Force

What is a transistor and how does it work?

What is a transistor?

Well, transistor is an electronically device created by our great predecessors. I think a good way to know this kind of human-made stuff is to understand its functionalities. In other words, to know why we created it in the first place. So, why?

We created transistors because we want to control an electronic circuit after it has been built. Image the circuit as a pipe system in a building. If this system doesn’t have valves, we will only be able to turn the whole system on or off, or maybe adjust the flow rate by regulating the overall supply (which actually also needs a valve that could be considered to be outside the system). Without valves, if someone in the 2nd floor want to take a shower, all faucets in the building will begin to flow water, which sucks. (Remember faucets have valves built in, so the assumption of no valves makes faucets uncontrollable.) Thus, we need valves for a pipe system, and we need transistors for an electronic circuit. ‘Transistor’ is just a professional name of ‘valve’ and ‘switch’ in the  field of electronics.

Faucet VS Transistor

How does a transistor work?

The transistor is designed to be a valve or switch, and it actually works like a valve or switch. It has three endpoints: base, collector, and emitter. When a certain voltage is applied between the base and the emitter, there will be a corresponding current flowing between the collector and the emitter. Thus, the input is the voltage between the base and the emitter, and the output is the current through the collector and the emitter.

In practice, the base terminal is connected to the control circuit, while the collector and the emitter is in the circuit that is being controlled. Note that the emitter is also present in the control circuit to form the control voltage difference.