2012年4月22日 星期日

DFF counter reference

Synchronous counter (D flipflops)

applet icon
The image above shows a thumbnail of the interactive Java applet embedded into this page. Unfortunately, your browser is not Java-aware or Java is disabled in the browser preferences. To start the applet, please enable Java and reload this page. (You might have to restart the browser.)


Circuit Description
A 4-bit synchronous counter built from D-flipflops with carry-input (count-enable) and carry-output. In this circuit, the single clock signal is directly connected to all flipflops, so that all flipflops change state at the same time.
Click the clock and nreset input switches or type the 'c' (clock), 'r' (reset), and 'x' (carry-in) bindkeys to operate the counter.
Obviously, this counter consists of four identical stages with a D-type flipflop, an XOR-gate, and a two-input AND-gate each. The XOR-gate in front of the D input of the flipflop basically converts the D-type flipflop into a toggle (T-type) flipflop. This is the same structure as the JK-flipflop with both J and K tied to logical-1, as shown in the previous applet.
While the carry-logic shown in the previous applet required an n-input AND gate for stage n, the carry-chain used in this applet is based on two-input gates. The difference in structure is similar to the carry-lookahead and the ripple-carry adders shown in the previous chapter. Obviously, the output of any AND gate is only high when all lower stage AND gates (and the carry input) are also high.
In other words,
Dn = Qn XOR (Qn-1 AND Qn-2 AND ... AND Q1 AND Q0 AND carry_in) 

[ref] http://tams-www.informatik.uni-hamburg.de/applets/hades/webdemos/30-counters/30-sync/sync-dff.html

A CMOS IC implementation of a "true single-phase edge-triggered flip-flop with reset"
 
[ref] http://en.wikipedia.org/wiki/Flip-flop_%28electronics%29
 

2012年4月13日 星期五

SSH login without password

1. execute this command as a normal user
>> ssh-keygen

2. in the ~/.ssh folder
>> cat id_rsa.pub >> authorized_keys

3. done

2012年4月9日 星期一

How to execute m-file in the Linux terminal background/foreground?

foreground execution in the terminal mode:
>> matlab -nojvm -nodisplay -nosplash

background execution in the terminal mode:
>> nohup matlab -nojvm -nodisplay -nosplash < 123.m > report123.log &

Ref:
[1]  http://www.math.ufl.edu/help/matlab/tec1.1.html

fonts in Centos 6 for matlab

'zero' and 'o' are distinguishable
    bitstream Vera Sans Mono
     DejaVu LGC Sans Mono
    Liberation Mono

Every letter has equal width
    Bitstream Vera Sans Mono
    Courier
    Courier 10 Pitch
    DejaVu LGC Sans Mono
     Dialoginput
    Liberation Mono
    Lucida Dans Typewriter
    Luxi Mono
    Monospaced
    Nimbus Mono L
    
Chinese words supported
    
    Dialog
    Dialoginput
    Monospaced
    SansSerif
     Serif
    ... other fonts with Chinese name
   
   
   

2012年4月7日 星期六

install nxserver on centos 6

I use matlab in linux server (centos)
Three remote control methods have different disadvantages..
XDMCP + SSH tunnel +matlab -->very very SLOW
VNC + Matlab--> crash sometimes and keypad disorders
   (press '0123456' in matlab command line, and the result shows '012456')
NXserver + Matlab --> lags when you scroll down in Matlab editor...
I can't find an excellent method in using Matlab in Centos 6...


Due to the application in a small group
the install guides on the internet are not suitable for me
so I write down some tips for myself

Environment:
Centos 6
SSH version 2 works well

Tips:
1. install
>> yum install nx freenx 

2. 
>> vi /etc/nxserver/node.conf
"SSHD_PORT=1234" 
"ENABLE_SSH_AUTHENTICATION="1"
 
>> vi /etc/ssh/sshd_config
"PasswordAuthentication yes" 

3.
service sshd restart 
 
4. 
nxserver --restart
 
5.
cat /var/lib/nxserver/home/.ssh/client.id_dsa.key
tell the client all the content of the file in some secret way
It may look like
"-----BEGIN DSA PRIVATE KEY-----
MIIBuwIBAAKBgQCXv9AzQXjxvXWskX9YomTfyG865gb4D02ZwWuRU/9
C3I9/bEWLdaWgJYkmWjjeSZyTmeoypI1iLifTHUxn3b7WNWi8AzKcVF
QU7TGVLk2CzY4dasrwxJ1f6FsT8DHTNGnxELPKRuR7KeafeFZDf+fJ3
mbX5nxrld3wi5titTnX+8s4IKv29HJguPvOK/SI7cjzA+SqNfD7qEo8CFDIm1xRf
8xAPsSKs6yZ6j1FNklfu
-----END DSA PRIVATE KEY-----" 
 
6.
download the client from the nomachine official website

 
 


2011年7月19日 星期二

Probability Density Function (pdf) of Sine Wave

Probability Density Function, f (x) , completely describes the probability that a Random Variable, X , assumes a value in a given range of possible values .
Mathematically, the probability that random variable X , assumes a value that lies in the interval [a,b] .
                             
The above equation represents the area under the curve f (x) from a to b . The limits of the above integral depend upon the domain of the f (x). However, the total area under the curve must not be greater 1 whatever the limits are. That is

  Another jargon often used with Probability Density Function is Cumulative Distribution Function (cdf). As the name implies it is the cumulative probability that a random variable X takes on a value equal or less than some specific value. For given value a, F(a) is the Cumulative Distribution Function that shows the probability that the random variable X assumes a value equal to or less than a . Mathematically shown as below

P(X < a) = F(a) ………….(3)
Cumulative Distribution Function is based on probability, it has following properties:
               
0 <= F(a) <=1
F(a 1 ) <= F(a 2 ) if a 1 < a 2
F(-∞) = 0
F(+∞) = 1
 
The relationship between Cumulative Distribution Function (cdf) and Probability Density Function (pdf) is shown below

That means the value of the F(a) is equal to the area under probability density function curve upto a .
From the above relationship, conversely, we have

Above two equations give us the relationship between cdf and pdf.

Following links provide a very simple understanding of pdf and cdf:
  • Engineered Software, Inc. ( pdf )
  • Engineered Software, Inc. ( cdf )
  • Wikipedia

Now for Probability Density Function of a sine wave. Let's say we have

X = sin(Y) ………………… (6)

A sine wave has been shown in figure below:


For equation (6), we already know that Y is uniformly distributed over [- pi/2   , pi/2] so X takes on a value in the range [-1, 1]. In this case, X is our random variable for which probability density function is given by eq (1). We aim to find the function f (x) for the sine wave given in eq (6).

Generally the inverse of a function provides the distribution of the values of that function which can be converted into Cumulative Distribution Function (cdf) after a little manipulation. These manipulations are done so that it fits with the definition of cdf.

We have random variable X which can assume a value in the interval [-1, 1]. Therefore

P(X < a) = P (sin(Y) < a) = P(Y < arcsin(a)) where -1<=a<=1  

Hence
Notice the modifications of dividing factor of and additive factor of ½ which have been done to make it compliant with the definition of Cumulative Distribution Function and its properties shown above.
Cumulative Distribution Function of a sine wave is shown below:


The possible values that a sine function can assume are shown along X-axis while probability is shown along Y-axis. The maximum probability can be 1.
Now making use of equation (5) above, we can calculate the Probability Density Function (pdf) of sine function (sine wave) by taking the derivative of equation (7). Hence pdf of sine wave is given below
This is quite intuitive that as the slope of a function increases at a value, the chances of occurring that value are higher. (Think of a straight line parallel to Y-axis which has infinite slope and has only one value occurring all the times along X-axis). The probability density function (pdf) of a sine wave, f (x), is shown below:  

The pdf shows that probability is high near the extreme values of -1 and 1 as most of the possible values occur towards the extreme values. For example, sine function reaches at 0.5 (half of its max amplitude) just at pi/6 (ie 30 degrees).  

All the above plots have been created from rechneronline.







[Ref] http://atif-razzaq.blogspot.com/2011/02/probability-density-function-pdf-of.html