Wednesday, December 23, 2009

How do we think? A brief introduction

Thinking about how we think is difficult, because thoughts of thoughts are limited by thoughts itself. But learning of how we think is essential in computing as well as AI powered robots. The basic reason of our thinking ability is a special type of cells in brain - neurons. A neuron is not perfectly known to human yet, but many similar models are proposed. The power of neurons is in its networking ability. Neurons are connected to each other and these complex networks may called as neural networks. I am not describing much about neurons because it is beyond our task. It's well enough if you just get an overview from Wikipedia. As I said, many convenient models are there to explain the behaviour of a neuron (Of course, a networked neuron is complex than a single one), but I am just touching simplest one named Perceptron. I will also mention back propagation during the example. I have pasted one figure from Wikipedia because you need it.The area in the shaded square can be considered as a neuron. x1,x2,......x7 are the inputs and w1,w2.......w7 are the corresponding weights (I will tell you what it is). and f is simply a function and outputs y. If the weighted sum of the inputs exceeds a particular threshold (which is previously be set), output y fires out. In actual neurons, y depends on other parameters such as input frequency. Since whole process in actual neurons are chemical, the explanation become rather complicated. But in all models we consider input as well as output signals are electrical in nature.I am explaining once again: first find
x1*w1+x2*w2+.........+x7*w7
If the resultant value is greater than a threshold (Typically 0), y=1; otherwise y=0.
I hope you understand something. But I know most of you are not satisfied because, you don't know what is really going on! Right?
Let me tell an example. This is a story. Here is you, Heroin is you.
Consider you have three friends and you(your brain) thinks that they are:
  • Albert - Your best friend. You have a confidence level of 0.7 on him. You trust him and ask his opinion before every important attempt
  • Deepika - Your classmate. Confidence level 0.3. Good personality.
  • Tom(me) - Confidence level of -0.55. Always say lie. Cheating personality.
These prejudice are taken by your brain from your experience. May be true or may not be.
The problem starts here. You are getting ready to go to your office/college. There are two ways to go. One is short path (easy way). Other is long. But short way has a problem is that sometimes it will be blocked. If you take the long path, you may reach the destination late. But if you choose the short path and in any case if blocked, you can't reach the destination on that day.
Then you come to know that today short way will be blocked. Then you consult your friends. Check their opinion:
  • Albert - Short road is not blocked. Damn sure.
  • Deepika - Someone told me about it. Short way may not be blocked. But I am not sure.
  • Tom - Hey man, road is blocked.
Can I go straight away through the short path?
Let's look how your brain solve the problem. Albert surely says that road is not blocked. Put a value of +0.95 for his opinion. The positive sign indicates that he is opposing. If Albert says sure that road blocked, the value may be -0.95. You don't know much about Deepika. But she may be right. Put a value of +0.1. Tom says it is blocked. So put -0.8.
Here threshold value is 0. If weighted sum is greater than 0. road is blocked. It is good to choose the long way. I not, road is not blocked, choose the short path.

Weighted sum is:
signal strength of Albert * confidence level+ signal strength of Deepika * confidence level+ signal strength of Tom * confidence level
=0.95*0.7 + 0.1*o.3 + (-0.8)*(-0.55)
=0.66+0.03+0.44
=1.13 which is greater than 0.

The brain successfully derived a decision for you. It is almost sure that road blocked with a confidence level of 1.13. Did you notice the analysis of Mr.Tom's opinion. You think tom is cheat. So the opposite of what he tells will be right. If you didn't understand the meaning of previous sentence just read one more time because some interesting things hidden in that sentence.

Ok, let's continue our story. Then you started going straight away through short path. You started journey in your own car but Alas! road is blocked. You couldn't just believe your eyes. but suddenly you realize the fact that you can't reach your destination today - you trapped in a huge road block.
Here, your brain attempts to rewire the entire circuitry inside it. Your thoughts were entirely wrong. Both Albert and Deepika was wrong, but Tom was right. You change the congedence level as,
  • Albert - 0.4 - I can't blive he cheated me.
  • Deepika - 0.1 - no coments.
  • Tom - 0.2 - oh, sorry Tom.
The actual working principle of neural networks is far deviated from the above story, but the fundamental thing in both is same. Actual neurons has a lot of diifernces and complexities than the neuron models

Tuesday, December 8, 2009

Go on with pyS60

I got a very good feedback from my previous post: "How to simulate PyS60 in your PC". As the request of opentechlab readers, I am attempting to write a brief beginner level tutorial on pyS60 emulator.

Once you are successful in installing and setting up the environment (If you didn't set up yet, click here), it is the time to go on.

Start the emulator program from:

Start->All programs -> S60 Developer tools -> 3rd edition FP2 SDK -> v1.1 -> Emulator

You probably need to wait for a couple of seconds to load it if your system is slow. Then a medium sized window with a full fledged mobile phone appears on the screen.

Now you need to open python. Just do as in your mobile phone. it's in Menu -> Installations -> python.

Now it's ready and do what you want.

Hacking python script

Select options -> Run script ->ball.py

You can move the ball anwhere in the screen. It's a physics simulation example in python. You can see the actual python script by opening ball.py file using any editor (notepad is not recommended. programmers notepad is good). The file is stored in :

C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\winscw\c\python

Search for the word 'blobsize'. Then you can find a line like:

blobsize = 16

Change the value of blobsize into 25 and save it. Then open ball.py in emulator. Did you notice any change? Similarly you can change acceleration, gravity (what about changing gravity into -0.01 ?) etc.

Developing your own programs

I am just starting with a hello world. Here is the program.

1)Simple hello world

print "Hello World!"

2)Say, hello world

from audio import*

say("Hello World!")

3)graphical hello world!

import appuifw
appuifw.note(u"Hello World!", "info")

It is good practice to make a short cut of python on the mobile desktop by changing options in settings.

Monday, December 7, 2009

How to simulate PyS60 in your PC

You can do your experiments in PyS60 without touching your mobile phone. The experimentation is easy while you set up everything in your PC. Here I am explaining how to set up the PyS60 environment in WinXP platform. I didn't try this attempt on my Linux yet. I will surely post about it if I get some good mobile stuff on Linux. This will be a boon for python developers in Nokia S60 mobile phones. But rarely it can be seen that some python scripts works neatly on simulator may cause strange responses on your real world system. I would like to here about it if you get any funny experience on your S60 device.
Download the required things:

1)Download S60_3rd_Edition_SDK_Feature_Pack_2_v1_1_en.zipfrom the following link:
http://www.forum.nokia.com/info/sw.nokia.com/id/807ec36d-0a8e-4bda-8e10-4d5e5bb4764a/S60_3rd_Edition_SDK_Feature_Pack_2_v1_1_en.zip.html


2)You can find ActivePerl 5.6.1 build 635 here:
http://downloads.activestate.com/Act...SWin32-x86.msi

3)Download PythonForS60 _1_4_5_SDK_3rdEdFP1.zip from http://sourceforge.net/projects/pys60/files/

First install ActivePerl because S60 SDK requires it.
Then install S60 SDK. Please note to install it in C:\ drive to avoid confusion.
Extract PythonForS60_1_4_5_SDK_3rdEdFP1.zip. Then you get another archived file sdk_files.zip.
Extract it again and you get a directory named 'epoc32'.
Copy this directory into "C:\S60\devices\S60_3rd_FP2_SDK_v1.1"
Then probably Windows XP asks to replace the already existing folder 'epoc32'. Click yes.
You have done. Cheers!

Sunday, December 6, 2009

Don't believe your eyes!


Don't believe your eyes, because everything you see, touch and feel is just a feeling only. Consider you are traveling in a space ship. No way to look outside. Space ship is traveling with higher velocity. If there is an obstacle present in front of the spaceship, sensors feel the presence of obstacle and it is reported on your computer. Then you turn the spaceship left or right. Then sensors feels that obstacle is removed (not obstacle, you!) and computer indicates that you can go straight way.
The above explained is a successful turning. But here I go in a something different way. The sensors are intelligent enough to send a fake signal that "there is some sort of obstacle" on the monitor. Actually, there is nothing in front of it. But your computer shows some obstacle. So you put a signal to turn right. Then the sensors shows that "now obstacle is removed. Go straight". You feel that you done well, but the sensor and the computer system really cheated you. Sometimes it was not a cheating, because ,there will be a possibility of thinking that there is an obstacle.
Our brain is not much different or error free in similar cases. If you are think that you know the universe, I think it is actually bad. Things you feeling from the surroundings may be different from reality. Your eyes are similar to the spaceship sensors. Not only your eyes, every sensors just see one phase of the reality. That really implies that knowing reality is too difficult.
I am not going too inside. I am not a philosopher. So let's have a fun. just go thruogh this link. A number of good eye illusions are included. Here I give a puzzle from eyetricks.com - Find which is longer?

Why there is so many constants in equations?

I will tell you the secret of constants in mathematical equations. They are not intruded or the error or nothing, but it is essential part of the equation. I will tell you some facts while going on your story. I will exemplify what you want in this story.
Consider you are a young scientist. You close your room's door and start experimenting on something when you get leisure time on Sundays. You are doing something seriously on your table, with an electrical circuit. Your aim is to find the dependence of a node voltage X (ie, a voltage in a part of the circuit). You came to know that X depend upon the supply voltage V. You start experimenting and plot graph of X for different values of V. Then you
got a graph like this:
It is perfectly linear. So you write,
X is directly proportional to V
To be more specific, X increases for an equivalent increase in V. You repeated your experiment and plot another characteristics with time. This time, your supply voltage kept constant. Plot X with time t.

From the plot, it easy to find that dependence is,

X is directly proportional to e^(-t)

Then from the above town experiments, you can write that,

X is directly proportional to V*e^(-t)
ie, X = K*V*e^(-t) where a K is the proportionality constant.

You can find K from single experiment. Once you got the value X when for a particular V and t,

K = X/(V*e^(-t)

But I want to tell you that your experiment as well as your mathematical expression is not perfectly true. A true dependence of X on it's environment will be very complex and tedious to express in mathematical form. Your X may depend on the atmospheric pressure, temperature, material properties,...raining in New Delhi,.....war on Iraq and so so.
After several years, you repeated your experiment and find that X depending on temperature also. Temperature has a direct linear relationship (like V) on X. But last time, you didn't got it. What's the reason? You were not aware of that, you did the experiment in room temperature itself. But this time you get different answers in day and chilled night. Now you modify your equation as,

X is directly proportional to V*T*e^(-t) where T is the temperature
X = L*V*T*e^(-t) where L is the proportionality constant.

Here I want a point to stress. Do you think your previous equation was wrong? Not at all. It is correct in an isothermal environment. But it become wrong in a temperature varying environment. A single measurement depending upon many things in the surroundings. But many of them can be ignored, because, they have less relationship with X. Something can't be ignored, but they may not be measurable (such as number of electron collision per second).In such cases, just put a constant for that, as long as they are constants. To be more clear, if your experiment depends upon the radius of earth, just put it as a constant in your equation. But when you do the experiment in moon, your experiment may troubled, unless you replaced the radius of earth with moon. I meant that variables can be considered as a constant or variable according to the environment.

Saturday, November 28, 2009

Puppy Linux : Give life to your Thumb drive

If you didn't tried Puppy Linux - one of the smallest Linux, core's yet-remember, you have only one life, try Puppy today itself. Puppy Linux - the name is not much inspiring for geeks, but I found it is the most stable and useful OS in the pocket Linux category.
It has the following advantages over other less-sized Linux operating systems.
  • Small sized. Ranges between 80MB to 150MB
  • Install anywhere - HDD, USB Pen drive, biz. card sized CDs. (You can use ordinary CDs, DVDs, Blu-ray discs - but it is too big for puppy.)
  • Easy to use.
  • Official website offers boot time of less than 1 minute. But it is typically less than 15s in my Intel P4 with 2GB RAM.
  • Puppy is beautiful than any other pocket OS.
  • Smart and crash free. I used more than 10 Linux flavors. Everything crashed, but I haven't experienced Puppy's crash.
  • Puppy sessions are saved in *.sfs file. It can be placed everywhere. Puppy search for it at boot time to recover the previous session. There are a number of fundamental advantages for that. I found many of my friend's computers not supporting USB boot. Of course they can boot from a CD-RW but it is not writable. Puppy offers several ways to overcome it. One is that, it can write previous sessions in CD as a multi session write. But it can be used until CD size limits. Another way is to write *.sfs file in HDD (for home usage) or USB pendrive ( for portability) and puppy kernel file in a a CD. So CD can be booted easily and can save sessions.
  • You can resize puppy save session file while running.
  • Comes with almost all drivers.
  • A wide variety of Puppy flavors are officially and unofficially available. These flavors are called 'Pupplets'. Pupplets are intended for a particular task - ie, it supports a task greatly. There are pupplets for painters, gamers, processionals, children, students and so on.
  • Brief and understanding tutorials, quick replying forums, community etc.
Once you downloaded Puppy, you have a lot of questions about installation, usage etc. Most of them answered in the official website and associated forums. Otherwise just google for that.

Wednesday, November 18, 2009

How to prevent virus from USB pendrive

Sometimes attacks of virus through USB pen drives are a real headache. Even though most of them are trivial, anti virus programs may not catch them. Use this following techniques in order to prevent them.
  • Make a raw file in the name same of a virus file. Most probably, these these files will be hidden. To view this, a good way is open the pen drive in Linux OS. you can see some names such as "virus.exe" on the root folder of pen drive. If it exists, open it using a text editor program and delete all the characters and if you want, include some raw characters and save. If you don't have any such files, but want to prevent them, you first of all need to find the name of that virus file and make a raw file in any text editor and save it in the same extension of the virus file. I successfully prevented a most common virus named "autorun.inf". Warning : This method not always work.
  • Use a good anti virus on your PC as well as in your pen drive. Some good links are http://www.usbantivirus.net/ and http://www.zbshareware.com/download.html
  • Format your pen drive well, if your head ache is cumbersome. Some virus programs can override quick format in windows. So use GParted.Prevention is better than cure. Formatting is the last chance.