Tuesday, August 31, 2010

Microsoft Windows with the X Windows System

Microsoft Windows users may also require an X Windows display server for running applications with a graphical user interface. We recommend Xming-mesa. This application is used along with PuTTY (see below section).
To use Xming, first start up Xming as follows:
Start -> Programs -> Xming -> Xlaunch
Accept the default settings.
Now, to access a server, connect to the server using PuTTY. Most of the default PuTTY settings are ok except you must check the box "Enable X11 forwarding" under the X11 configuration category. PuTTY will prompt you for your username and password. Start the desired X-Windows application in the resulting terminal window.


OS X with the X Windows System
For the X Windows system, use the X11 application which comes with OS X. It may need to be separately installed from the operating system or downloaded from the Apple website. It will be in the Utilities folder which is in the Applications folder. Open X11, then from the "Applications" menu, choose "Terminal". In the terminal window that presents, enter the following replacing hostname as required (remember the -X!):
ssh -X hostaddress


Microsoft Windows with ssh
Microsoft Windows does not come with an ssh client program. Therefore, we recommend that you download and install PuTTY (terminal program) and WinSCP (file transfer program).

SPSS job interview questions

 
1. What is data view and variable view?
• In Data View, columns represent variables, and rows represent cases (observations).
• In Variable View, each row is a variable, and each column is an attribute that is associated with that variable.



2. What statistics analysis is included in SPSS?
3. How to calculate the effect of educational intervention to drug prescription?
We can input the drug prescription status  (yes or no) before and after educational intervention.  We can calculate the odds ratio using logistic regression in SPSS.

4. How to calculate the effect of educational intervention to drug dose in prescription?

 We used a matched pair for magnitude of drug dose before and after intervention  and analyze it using  student t-test in SPSS.

Hypothesis test -- statistics

1) Null hypothesis:
The null hypothesis (denote by H0 ) is a statement about the value of
a population parameter (such as mean), and it must contain the condition of equality and must be written with the symbol =, ≤, or ≤.


2. Alternative hypothesis
The Alternative hypothesis (denoted by H1 ) is the statement that must be true if the null hypothesis is false.

Conclusion
a) Fail to reject the null hypothesis
b) Reject the null hypothesis.

Significance level
The probability of rejecting the null hypothesis when it is called
the significance level α , and very common choices are
α = 0.05 and α = 0.01

Example:
A sample of data for body temperature (n=106, x̄=98.20°, s =0.62),
for a 0.05 significance level, test the claim that the mean body temperature of health adults is equal to 98.6°F.



Solution: We have:
H0 : μ=98.6 (original claim) H1 : μ≠98.6
As n>30, the central limit theorem indicates that the distribution of sample means can be approximated by a normal distribution
z= (x̄ - μ)/ (σ/√n) = (98.20-98.6)/(0.62/√106) = -6.64
The test is two-sided because a sample mean significantly less than or greater than 98.6 is strong evidence against the null hypothesis that μ=98.6.
α/2 = 0.025, the left critical z value = -1.96, right z critical value = 1.96. For z between -1.96 and 1.96, we fail to reject H0.
As z = -6.64, we reject the reject H0 i.e. we reject the hypothesis that the mean body temperature of health adults is equal to 98.6°F.

Central Limit Theorem--statistics

As the sample size increases, the sampling distribution of sample
means approaches a normal distribution

If all  possible random samples of size n are selected from a population with mean μ and standard deviation σ, the mean of the sample means is denoted by μ, so
μ = μ
the standard deviation of the sample means is:
σ = σ⁄ n


Example:  Given that the population of men has normally distributed weights, with a mean of 173 lb and a standard deviation of 30 lb, find the probability that
a. if 1 man is randomly selected, his weight is greater than 180 lb.
b. if 36 different men are randomly selected, their mean weight is greater that 180 lb.


Solution: a) z = (x - μ)/ σ = (180-173)/30 = 0.23
For normal distribution P(Z>0.23) = 0.4090
b) σ = σ/n = 20/√ 36 = 5
z= (180-173)/5 = 1.40
P(Z>1.4) = 0.0808

Binomial Probability Formula--statistics

P(x)= p x q n-x n!/[(n-x)!x!]
where x = number of trials
x = number of successes among n trials
p = probability of success in any one trial
q = 1 -p



Example: Find the probability of getting 3 left-handed students in a class of 15 students, given that 10% of us are left-handed.
Solution: here n = 15, x=3, p =0.1, q =0.9
p(3) = 0.129, the probability is 12.9%

math formula in html

Superscript and Subscript

With the Tags

You can use the <sup></sup> tag to create superscript text and <sub></sub> to create su-script text. Or you can use the codes below.
Code: x<sup>x+1</sup>
Result: xx+1
Code: x<sub>i+1</sub>


Result: xi+1

With the Codes

Code: x&sup2;

Result:
Code: x&#8308;



Result: x⁴
More detail see the link

Special Characters in HTML





left single quote&lsquo;
right single quote&rsquo;
single low-9 quote&sbquo;
left double quote&ldquo;
right double quote&rdquo;
double low-9 quote&bdquo;
dagger&dagger;
double dagger&Dagger;
per mill sign&permil;
single left-pointing angle quote&lsaquo;
single right-pointing angle quote&rsaquo;
black spade suit&spades;
black club suit&clubs;
black heart suit&hearts;
black diamond suit&diams;
overline, = spacing overscore&oline;
leftward arrow&larr;
upward arrow&uarr;
rightward arrow&rarr;
downward arrow&darr;
trademark sign&#x2122;&trade;
unused&#00;-
&#08;
horizontal tab&#09;
line feed&#10;
unused&#11;
space&#32;
exclamation mark&#33;!
double quotation mark&#34;&quot;"
number sign&#35;#
dollar sign&#36;$
percent sign&#37;%
ampersand&#38;&amp;&
apostrophe&#39;'
left parenthesis&#40;(
right parenthesis&#41;)
asterisk&#42;*
plus sign&#43;+
comma&#44;,
hyphen&#45;-
period&#46;.
slash&#47;&frasl;/
digits 0-9&#48;-
&#57;
colon&#58;:
semicolon&#59;;
less-than sign&#60;&lt;<
equals sign&#61;=
greater-than sign&#62;&gt;>
question mark&#63;?
at sign&#64;@
uppercase letters A-Z&#65;-
&#90;
left square bracket&#91;[
backslash&#92;\
right square bracket&#93;]
caret&#94;^
horizontal bar (underscore)&#95;_
grave accent&#96;`
lowercase letters a-z&#97;-
&#122;
left curly brace&#123;{
vertical bar&#124;|
right curly brace&#125;}
tilde&#126;~
unused&#127;-
&#149;
en dash&#150;&ndash;
em dash&#151;&mdash;
unused&#152;-
&#159;
nonbreaking space&#160;&nbsp;
inverted exclamation&#161;&iexcl;¡
cent sign&#162;&cent;¢
pound sterling&#163;&pound;£
general currency sign&#164;&curren;¤
yen sign&#165;&yen;¥
broken vertical bar&#166;&brvbar; or &brkbar;¦
section sign&#167;&sect;§
umlaut&#168;&uml; or &die;¨
copyright&#169;&copy;©
feminine ordinal&#170;&ordf;ª
left angle quote&#171;&laquo;«
not sign&#172;&not;¬
soft hyphen&#173;&shy;­
registered trademark&#174;&reg;®
macron accent&#175;&macr; or &hibar;¯
degree sign&#176;&deg;°
plus or minus&#177;&plusmn;±
superscript two&#178;&sup2;²
superscript three&#179;&sup3;³
acute accent&#180;&acute;´
micro sign&#181;&micro;µ
paragraph sign&#182;&para;
middle dot&#183;&middot;·
cedilla&#184;&cedil;¸
superscript one&#185;&sup1;¹
masculine ordinal&#186;&ordm;º
right angle quote&#187;&raquo;»
one-fourth&#188;&frac14;¼
one-half&#189;&frac12;½
three-fourths&#190;&frac34;¾
inverted question mark&#191;&iquest;¿
uppercase A, grave accent&#192;&Agrave;À
uppercase A, acute accent&#193;&Aacute;Á
uppercase A, circumflex accent&#194;&Acirc;Â
uppercase A, tilde&#195;&Atilde;Ã
uppercase A, umlaut&#196;&Auml;Ä
uppercase A, ring&#197;&Aring;Å
uppercase AE&#198;&AElig;Æ
uppercase C, cedilla&#199;&Ccedil;Ç
uppercase E, grave accent&#200;&Egrave;È
uppercase E, acute accent&#201;&Eacute;É
uppercase E, circumflex accent&#202;&Ecirc;Ê
uppercase E, umlaut&#203;&Euml;Ë
uppercase I, grave accent&#204;&Igrave;Ì
uppercase I, acute accent&#205;&Iacute;Í
uppercase I, circumflex accent&#206;&Icirc;Î
uppercase I, umlaut&#207;&Iuml;Ï
uppercase Eth, Icelandic&#208;&ETH;Ð
uppercase N, tilde&#209;&Ntilde;Ñ
uppercase O, grave accent&#210;&Ograve;Ò
uppercase O, acute accent&#211;&Oacute;Ó
uppercase O, circumflex accent&#212;&Ocirc;Ô
uppercase O, tilde&#213;&Otilde;Õ
uppercase O, umlaut&#214;&Ouml;Ö
multiplication sign&#215;&times;×
uppercase O, slash&#216;&Oslash;Ø
uppercase U, grave accent&#217;&Ugrave;Ù
uppercase U, acute accent&#218;&Uacute;Ú
uppercase U, circumflex accent&#219;&Ucirc;Û
uppercase U, umlaut&#220;&Uuml;Ü
uppercase Y, acute accent&#221;&Yacute;Ý
uppercase THORN, Icelandic&#222;&THORN;Þ
lowercase sharps, German&#223;&szlig;ß
lowercase a, grave accent&#224;&agrave;à
lowercase a, acute accent&#225;&aacute;á
lowercase a, circumflex accent&#226;&acirc;â
lowercase a, tilde&#227;&atilde;ã
lowercase a, umlaut&#228;&auml;ä
lowercase a, ring&#229;&aring;å
lowercase ae&#230;&aelig;æ
lowercase c, cedilla&#231;&ccedil;ç
lowercase e, grave accent&#232;&egrave;è
lowercase e, acute accent&#233;&eacute;é
lowercase e, circumflex accent&#234;&ecirc;ê
lowercase e, umlaut&#235;&euml;ë
lowercase i, grave accent&#236;&igrave;ì
lowercase i, acute accent&#237;&iacute;í
lowercase i, circumflex accent&#238;&icirc;î
lowercase i, umlaut&#239;&iuml;ï
lowercase eth, Icelandic&#240;&eth;ð
lowercase n, tilde&#241;&ntilde;ñ
lowercase o, grave accent&#242;&ograve;ò
lowercase o, acute accent&#243;&oacute;ó
lowercase o, circumflex accent&#244;&ocirc;ô
lowercase o, tilde&#245;&otilde;õ
lowercase o, umlaut&#246;&ouml;ö
division sign&#247;&divide;÷
lowercase o, slash&#248;&oslash;ø
lowercase u, grave accent&#249;&ugrave;ù
lowercase u, acute accent&#250;&uacute;ú
lowercase u, circumflex accent&#251;&ucirc;û
lowercase u, umlaut&#252;&uuml;ü
lowercase y, acute accent&#253;&yacute;ý
lowercase thorn, Icelandic&#254;&thorn;þ
lowercase y, umlaut&#255;&yuml;ÿ
Alpha&Alpha;Α
alpha&alpha;α
Beta&Beta;Β
beta&beta;β
Gamma&Gamma;Γ
gamma&gamma;γ
Delta&Delta;Δ
delta&delta;δ
Epsilon&Epsilon;Ε
epsilon&epsilon;ε
Zeta&Zeta;Ζ
zeta&zeta;ζ
Eta&Eta;Η
eta&eta;η
Theta&Theta;Θ
theta&theta;θ
Iota&Iota;Ι
iota&iota;ι
Kappa&Kappa;Κ
kappa&kappa;κ
Lambda&Lambda;Λ
lambda&lambda;λ
Mu&Mu;Μ
mu&mu;μ
Nu&Nu;Ν
nu&nu;ν
Xi&Xi;Ξ
xi&xi;ξ
Omicron&Omicron;Ο
omicron&omicron;ο
Pi&Pi;Π
pi&pi;π
Rho&Rho;Ρ
rho&rho;ρ
Sigma&Sigma;Σ
sigma&sigma;σ
Tau&Tau;Τ
tau&tau;τ
Upsilon&Upsilon;Υ
upsilon&upsilon;υ
Phi&Phi;Φ
phi&phi;φ
Chi&Chi;Χ
chi&chi;χ
Psi&Psi;Ψ
psi&psi;ψ
Omega&Omega;Ω
omega&omega;ω
password dot&#9679;
bullet&#8226;

Sunday, August 29, 2010

C++ interview questions (4)

22. what is importance of const. pointer in copy constructor?
 When we try to  copy one object into another using copy constructor,we need to maintain the original copy of original object (which we are copying) so while passing object we make it constant and we pass it as a by reference.


 23. What is a memory leak? How can we avoid it?
A memory leak or leakage in computer science occurs when a computer program consumes memory but is unable to release it back to the operating system.
A memory leak can be avoided by making sure that whatever memory has been dynamically allocated will be cleared after the use of the same. for example
#include<iostream>
using namespace std;

void func()
{
int *a = new int; //on heap

int b; // on stack
//avoid memeory leakage
delete a; //deleting memory on heap
}

int main()
{

func();
cout<<"end of main"<<endl;
return (0);
}


 
24. Why always array starts with index 0?
  This boils down to the concept of Binary digits.
Take an array size of 64 for example. We start from 0 and 
end at 63. We require 6 bits.But, if we were to start from 
1 and end at 64, we would require 7 bits to store the 
same number, thus increasing the storage size.
 
25 What is  stringstream? Give an example.
stringstream provides an interface to manipulate strings 
as if they were input/output streams. 

Members inherited from istream

istream& getline (char* s, streamsize n );
istream& getline (char* s, streamsize n, char delim );
Following is a sample program using a stringstream 
to read numbers from a csv file named "input.txt" into
a 6 row by 5 column int array and
then prints the array.

It can take data from an input (text) file that
looks like this: 
1,3,10,3,1
1,10,10,3,10
1,,,,
0,0,0,1,10
1,1,0,2,2
10,1,0,1,10

 

 
#include <iostream>
#include <fstream>

#include<sstream>
using namespace std;

int ROWS = 6;

int COLS = 5;
int BUFFSIZE = 80;

main() {
 int array[ROWS][COLS];
 char buff[BUFFSIZE]; // a buffer to temporarily park the data

 ifstream infile("input.txt");
 stringstream ss;
 for( int row = 0; row < ROWS; ++row ) {

   // read a full line of input into the buffer (newline is
   //  automatically discarded)
   infile.getline( buff,  BUFFSIZE );
   // copy the entire line into the stringstream

   ss << buff;
   for( int col = 0; col < COLS; ++col ) {

     // Read from ss back into the buffer.  Here, ',' is
     //  specified as the delimiter so it reads only until
     //  it reaches a comma (which is automatically
     //  discarded) or reaches the 'eof', but of course
     //  this 'eof' is really just the end of a line of the
     //  original input.  The "6" is because I figured
     //  the input numbers would be 5 digits or less.
     ss.getline( buff, 6, ',' );

     // Next, use the stdlib atoi function to convert the
     //  input value that was just read from ss to an int,
     //  and copy it into the array.
     array[row][col] = atoi( buff );
   }

   // This copies an empty string into ss, erasing the
   //  previous contents.
   ss << "";
   // This clears the 'eof' flag.  Otherwise, even after
   //  writing new data to ss we wouldn't be able to
   //  read from it.
   ss.clear();
 }

 // Now print the array to see the result
 for( int row = 0; row < ROWS; ++row ) {

   for( int col = 0; col < COLS; ++col ) {

     cout << array[row][col] << " ";
   }
   cout << endl;
 }

 infile.close();
}

server client and socket programming-C++

Server:
1)Establish a listening socket and wait for connections from clients.
2)Accept the client's connection attempt.
3)Send and receive data.
4) Close the connection.



Client:
 1) Create a client socket and attempt to connect to server.
2) Send and receive data.
3) Close the connection.

File Download site 
Makefile: Makefile for this project
Socket.h:  define Socket class and declare server  function  create, bind, listen, accept client function: connect, data function send, recv
SocketException.h: define SocketException class to deal with
class method fail. If a class method fails for any reason, it throws an exception of type SocketException.
SeverSocket.h:   define SeverSocket class derived from Socket class, redefine accept method and  define overloaded the << and >> operators, so that when used, they wrote data to and read data from the socket.
ClientSocket.h: define ClientSocket class derived from Socket class,
define overloaded the << and >> operators, so that when used, they wrote data to and read data from the socket.
Socket.cpp, ServerSocket.cpp and Client.Socket.cpp detaily define
methods declared in header file
simple_server_main.cpp:  a simple implementation of a server
The new_sock variable contains all of our socket information, so we use it to exchange data with the client. The line "new_sock >> data;" should be read as "read data from new_sock, and place that data in our string variable 'data'." Similarly, the next line sends the data in 'data' back through the socket to the client.


If you're paying attention, you'll notice that what we've created here is an echo server. Every piece of data that gets sent from the client to the server gets sent back to the client as is. We can write the client so that it sends a piece of data, and then prints out the server's response:
simple_client_main.cpp: a simple implementation of a client
We send the string "Test Message." to the server, read the response from the server, and print out the response to std output. 

Saturday, August 28, 2010

C++ interview questions (3)

19. What is function template and class template?
Function templates are special functions that can operate with generic types.

template <class myType>
myType GetMax (myType a, myType b) {
 return (a>b?a:b);
}
example:
int a=GetMax(1,2);
double b=GextMax(1.0,2.0); 


Class template have members that use template parameters as types
template <class T>
class mypair {
    T values [2];
  public:
    mypair (T first, T second)
    {
      values[0]=first; values[1]=second;
    }
};
Example:
 
mypair<int> myobject (115, 30);
mypair<double> myfloats (3.03, 2.28); 
 

 
20 .What is POLYMORPHISM and give an example using eg. SHAPE object: If I have a base class SHAPE, how would I define DRAW methods for two objects CIRCLE and SQUARE
POLYMORPHISM : A phenomenon which enables an object to react differently to the same function call.
in C++ it is attained by using a keyword virtual
example
public class SHAPE
{
public virtual void SHAPE::DRAW()=0;
};
Note here the function DRAW() is pure virtual which means the derived classes must implement the DRAW() method.
public class CIRCLE::public SHAPE
{
public void CIRCLE::DRAW()
{
// TODO drawing circle
}
};
public class SQUARE::public SHAPE
{
public void SQUARE::DRAW()
{
// TODO drawing square
}
};





21. What is virtual function? Give an example to explain using/not using virtual function.
  C++ virtual function is a member function of a class, whose functionality can be over-ridden in its derived classes. 


#include<iostream>
using namespace std;

 class Window // Base class for C++ virtual function example
     {
       public:
          virtual void Create() // virtual function for C++ virtual function example
        //     void Create()

          {
               cout <<"Base class Window"<<endl;
          }
     };

     class CommandButton : public Window

     {
       public:
          void Create()
          {
              cout<<"Derived class Command Button - Overridden C++ virtual function"<<endl;
          }
     };

     int main()
     {
         Window  *x, *y;

         x = new Window();
         x->Create();

         y = new CommandButton();
         y->Create();
         return(0);
     }
If the function create  is declared virtual, the following output is given: 
Base class Window
Derived class Command Button - Overridden C++ virtual function
If the function create is not declared virtual, the following output
is given 
Base class Window
Base class Window
The base function create is kept calling.

Friday, August 27, 2010

C++ interview Questions (2)

Question 1-11 see:
C++ interview Questions (1)


12. You’re given a simple code for the class 
Circle. Write the following functions:
 
  • Copy constructor
  • = operator overload
  • == operator overload
  • + operator overload
Class  Circle{
    private:
          double  r;
    public:
          Circle(double r0);
          Circle(const Circle& myCircle); //copy constructor 
  //= operator overload
Circle& operator=(const Circle& myCircle);
//== operator overload 
int operator==(const Circle& myCircle1, const Circle& myCircle2); 
//+ operator overload
Circle& operator+(const Circle& myCircle1, const Circle& myCricle2 );
 }; 
Circle::Circle(double r0){
             r = r0;
}
Circle::Circle(const Circle& myCircle){
     this.r = myCircle.r;
}
Circle& Circle::operator=(const Circle& myCircle)

{

    r = myCircle.r;
    return *this;

}
int Circle::operator==(const Circle& myCircle1, const Circle& myCircle2)

{

    return (myCircle1==myCircle2);

}
Circle& Circle::operator+(const Circle& myCircle1, const Circle& myCircle2)

{

    r = myCircle1.r+myCircle2.r;
    return *this;

}

int main(){
      Circle FirstCircle(2.0);
      Circle SecondCircle=FirstCircle;// this invokes the copy constructor
      return 0;
}
13 What memory part is accessed when you run a program?
heap
 dynamic memory allocation (also known as heap-based memory 
allocation) is the allocation of memory storage for use in 
a computer program during the runtime of that program.
Static memory allocation refers to the process of allocating
memory at compile-time before the associated program is executed.
Stacks in computing architectures are regions of memory 
where data is added or removed in a last-in-first-out manner, 


while heap is first-in-first-out.
stack allocation is very simple and typically faster than
heap allocatio.


14. For an empty class, what method is accessed?
default constructor, copy constructor, destructor

15. binary tree, array, hashed table, which one can be
 random accessed?
array

16. What is default constructor?
What a class is created, default constructor is automatically
called to initialize the class.


17. Which member can be accessed by a derived class?
public member and protected member.
 
18. What is object oriented programming? What is class and object?
What is difference between class and object? 
Object-oriented programming (OOP) is a programming paradigm that uses "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. A class is a definition of an object. Object is an instance of a class.
Every object belongs to a class and every class contains one or more related objects.

18.  Describe C/C++ Standard  Template Library (STL).
The Standard Template Library (STL) is a software library partially included in the C++ Standard Library. It provides containers, iterators, algorithms, and functors. More specifically, the C++ Standard Library is based on the STL published by SGI.
C++ Standard Library

    * ios, iostream, iomanip, fstream, sstream

Standard Template Library

    * vector, deque, list, map, set, stack, queue, bitset, algorithm
    * functional,iterator

C Standard Library

    * cassert, cctype, cerrno,climits, clocale, cmath
    * csetjmp, csignal, cstdarg, cstddef
    * cstdio, cstdint, cstdlib, cstring, ctime

My pipe job list

I create several  job lists using yahoo pipe:

1. computer job in Vancouver
2. Physics jobs in Canada
3. University and college jobs near Vancouver

Thursday, August 26, 2010

Create a thread in C/C++



A thread of execution is the smallest unit of processing that can be scheduled by an operating system. It generally results from a fork of a computer program into two or more concurrently running tasks.


The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process. Multiple threads can exist within the same process and share resources such as memory, while different processes do not share these resources.
compile:
g++  -lpthread thread.c

thread.c as following


-----------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

void *print_message( void *ptr )
{
   printf("%s \n", (char*) ptr);
}
int main()
{
     pthread_t thread1;
     char *m = "Thread 1";
     int  iret1;
    /* Create a  thread each to execute function */
    /* message1 pass to function print_message*/
iret1 = pthread_create( &thread1, NULL, print_message, (void*) m);
     /* pthread_join - wait for termination of another thread*/
     pthread_join( thread1, NULL);

     printf("Thread 1 returns: %d\n",iret1);

     return(0);

}




 ------------------------------------------------
 Pipes can be used in threads and processes. The program below
demonstrates how pipes can be used in processes. A new process can be
created using the system call fork(). It returns two differnt values to
the child and parent. The value 0 is returned to the child (new)
process and the PID (Process ID) of the child is returned to the parent
process. This is used to distinguish between the two processes. In the
program given below, the child process waits for the user input and
once an input is entered, it writes into the pipe. And the parent
process reads from the pipe.
 
Note here that the pipe() system call was called before the system call fork(). The buffer allocated to the pipe is accessible to both the processes.

g++ pipe_test.c
below is pipe_test.c 
 

#include <stdlib.h>
#include <stdio.h>

#include <unistd.h>

/* Write COUNT copies of MESSAGE to STREAM, pausing for a second
   between each.  */

void writer (const char* message, int count, FILE* stream)
{

  for (; count > 0; --count) {
    /* Write the message to the stream, and send it off immediately.  */
    fprintf (stream, "%s\n", message);

    fflush (stream);
    /* Snooze a while.  */
    sleep (1);
  }
}

/* Read random strings from the stream as long as possible.  */

void reader (FILE* stream)
{
  char buffer[1024];

  /* Read until we hit the end of the stream.  fgets reads until
     either a newline or the end-of-file.  */
  while (!feof (stream) 
  && !ferror (stream) 
  && fgets (buffer, sizeof (buffer), stream) != NULL) 
    fputs (buffer, stdout);
} 
int main ()
{
  int fds[2];
  pid_t pid;

  /* Create a pipe.  File descriptors for the two ends of the pipe are
     placed in fds.  */
  pipe (fds);
  /* Fork a child process.  */
  pid = fork ();

  if (pid == (pid_t) 0) {
    FILE* stream;

    /* This is the child process.  Close our copy of the write end of
       the file descriptor.  */
    close (fds[1]);
    /* Convert the read file descriptor to a FILE object, and read
       from it.  */
    stream = fdopen (fds[0], "r");

    reader (stream);
    close (fds[0]);
  }
  else {

    /* This is the parent process.  */
    FILE* stream;
    /* Close our copy of the read end of the file descriptor.  */
    close (fds[0]);

    /* Convert the write file descriptor to a FILE object, and write
       to it.  */
    stream = fdopen (fds[1], "w");

    writer ("Hello, world.", 5, stream);
    close (fds[1]);
  }

  return 0;
}

Wednesday, August 25, 2010

statistics analysis in Matlab

1) Mode:
The mode of a data sample is the element that occurs most often in the collection.
x=[1 2 3 3 3 4 4]
mode(x) % return 3, happen most
2)Median:
a median is described as the numeric value separating the higher half of a sample, a population, or a probability distribution, from the lower half. The median of a finite list of numbers can be found by arranging all the observations from lowest value to highest value and picking the middle one
median(x) % return 3
3)  mean
Total sum divided by number of values
mean(x) % return 2.8571


4)  quartile
first quartile (25th percentile)
second quartile (50th percentile)
third quartile (75th percentile)
kth percentile
prctile(x, 25) % 25th percentile, return 2.25
prctile(x, 50) % 50th percentile, return 3, i.e. median

5) skewness
Skewness is a measure of the asymmetry of the data around the sample mean. If skewness is negative, the data are spread out more to the left of the mean than to the right. If skewness is positive, the data are spread out more to the right.
skewness(x) % return-0.5954
6)kurtosis
Kurtosis is a measure of how outlier-prone a distribution is.
kurtosis(x) % return2.3594
7)  Standard deviation
the square root of an unbiased estimator of the variance of the population from which X is drawn, as long as X consists of independent, identically distributed samples.
std(x) %return 1.0690
8) Variance
describes how far values lie from the mean
var(x)  %return 1.1429
9)  moment
 a quantitative measure of the shape of a set of points.
moment(x, 2); %return second moment
10. covariance
measure of how much two variables change together
y2=[1 3 4 5 6 7 8]
cov(x,y2) %return 2*2 matrix, diagonal represents variance
11.Linear Regression:
  modeling the relationship between a scalar variable y and one or more variables denoted X. In linear regression, models of the unknown parameters are estimated from the data using linear functions.
polyfit( x,y2,1) %return 2.1667   -1.3333, i.e 2.1667x-1.3333
12. One sample t-test
A t-test is any statistical hypothesis test in which the test statistic follows a Student's t distribution if the null hypothesis is supported.
[h,p,ci] = ttest(y2,0)% return  1    0.0018 ci =2.6280    7.0863


This time the test rejects the null hypothesis at the default α = 0.05 significance level. The p value has fallen below α = 0.05 and the 95% confidence interval on the mean does not contain 0.
Because the p value of the sample y is greater than 0.01, the test will fail to reject the null hypothesis when the significance level is lowered to α = 0.01:

Tuesday, August 24, 2010

Jobs in Vancouver in Science & Technology

Cold call in job search



A cold call is a very effective way for searching hidden job market.
The goal of cold call is to lead to a job interview.
But a lot of  people don't use cold call because:

  • It's scary to do



  • It uses scripted, forced conversations that sound like a sales pitch



  • The fear of being rejected or not knowing what to say



  • In cold call, followings steps to follow:
    1) Introduction: "Hi, I am Jiansen Lu"
    2) Give a brief explanation of your work background and your level of experience. ie. "I'm a software programmer with 10 years  experience. Can I talk to the hiring manager
    to enquire the job opportunity in your company?"
     3)Finally ask for an interview. ie. "When can I meet with you in person"
    I use goolg map to search
    "IT company in Vancouver" and start cold calls.
    1) PrimeObects, tel:Vancover, BC Canada
    +1 (604) 807-7068(General inquiry)

    result: voicemail
    2) PCIS career (recruiter)

    Monday, August 23, 2010

    C++ company directory in Vancouver

    job
    B
    301 Wayburne Drive, Burnaby, BC V5G4X4‎ - (778) 881-4161
    Category: Software Company
    "Integrio delivers a full spectrum of IT services including custom software development, web design, and consulting. We are experienced in Java, EJB, JSP ..."ic.gc.ca
    C

    D
    E

    1130 West Pender Street #610, Vancouver, BC V6E4A4‎ - (604) 682-4652
    Category: Computer Software
    "In the most exciting software related news I've heard in years ESRI and Carlson have joined forces to better serve their clients. As I indicated in my ..."blogspot.com
    F

    910 Mainland Street, Vancouver, BC V6B1A9‎ - (604) 602-7577
    Category: Computer Software
    "28, 2000 — Seagate Software Inc., a leader in enterprise reporting and analysis, and Microsoft Corp. today announced that Microsoft will include Crystal ..."microsoft.com
    G



    201 - 1640 Electra Boulevard, Sidney, BC V8L 5V4‎ - (250) 953-7508
    "Following position was posted today on one of the employer's web site: Senior C/C++ Software Developer , IBM Canada Location: BC-Victoria Please ..."victoria-jobs.ca
    H

    2329 West Mall, Vancouver, BC V6T 1Z4‎ - (604) 822-2211
    "Utilized C/C++, OpenGL, DirectX 8.0, Computer Graphics, Mathematics Software Engineer Intern, Shenzhen Silvan Technologies Development Co., Ltd ..."chenyang-web.com


    I
    3376 East 44 Avenue, Vancouver, BC V5R 3B4‎ - (604) 454-8483
    Category: Services - Software Development
    "Proven ability to work with clients and lead a team of software developers to plan, design and implement Windows, OS X, Linux and web based applications ..."danzisoft.ca
    J

    8888 University Drive, Burnaby, BC V5A 1S6‎ - (778) 782-4187
    "Andrew Sutton , Jonathan I. Maletic, Recovering UML class models from C++: A detailed explanation, Information and Software Technology, v.49 n.3, p ..."acm.org


    A

    1114 West Broadway #201, Vancouver, BC V6H 1G5‎ - (604) 438-4357
    "Net technology as well as C++. Software outsourcing India - Offshore software development : eTatvaSoft is an software development company with clear ..."vancouver-webpages.com
    B

    3700 WILLINGDON AVE, Burnaby, British Columbia V5G 3H2‎ - (604) 434-5734
    "Software Skills: 5+ years of experience with C#, 5+ years of experience with Java, Delphi, Win32, C/C++, VB6, SMS, MMS, Windows CE (. ..."frankyhsu.com
    C
    West Hastings Street, Vancouver, BC V6B 1L8‎ - (778) 588-6896
    Category: Computer Software
    ""The software development tools for ALM deployed in most organizations are heterogeneous due to the presence of legacy systems, new agile tools and a ..."tasktop.com
    D
    Park Royal South, West Vancouver, BC V7T 1A2‎ - (604) 921-5993
    Category: Computer Software
    "The Eyeball AnyFirewall™ Engine is the industry's leading Firewall and NAT traversal Software Development Kit, offering the most comprehensive ..."anyfirewallengine.com
    E

    4004 Wesbrook Mall, Vancouver, BC V6T 2A3‎ - (604) 222-1047
    "We also evaluate and recommend various free and commercial software products and provide consultation with users on programs and libraries, programming ..."triumf.ca
    F
    130-4311 Viking Way, Richmond, BC V6V2K9‎ - (604) 279-8550
    "Additional software plug-ins can be developed in Matlab, Visual C++, communicate and synchronize with peripherals connected to the system. ..."ultrasonix.com
    G
    Howe Street, Vancouver, BC V6Z 2T1‎ - (604) 683-6711
    "Metasoft Systems straddles two software niches. The company's Imager division provides software components that developers of imaging applications use ..."yahoo.com
    H
    4Flr-1401 8th Avenue West, Vancouver, BC V6H 1C9‎ - (604) 685-7619
    "Cheers, > > David Neufeld > > Sr. Systems Administrator - Technical Lead > > > > tel 604.608.6026 > > david.neufeld@xxxxxxx > > > > Alea Software Ltd. ..."osdir.com
    I

    3350 Spitfire, Cassidy, BC V0R 1H0‎ - (250) 245-2157
    "It's nice to see some news sources running stories on our software development at Ecotrust. We received a Mellon Award last week in DC for our work ..."tdubya.net
    J

    7445 132 Street #2017, Surrey, BC V3W 1J8‎ - (604) 501-9985
    "Supported interfaces include: Java, C++, C, COM (VB), .NET (C#, VB.NET), Delphi and ArcView Avenue. A free evaluation is available from Safe Software's ..."svgopen.org

    A

    855 West 12th Avenue, Vancouver, BC V5Z 1M9‎ - (604) 875-4111
    "UI Software Developer, Kodak (ex-Creo), Vancouver. I spend most of my time implementing client-side UI in C++ for both Mac and PC. The tools I use most ..."tristanmoss.net
    B

    845 BURRARD ST, Vancouver, British Columbia V6Z 2K6‎ - (604) 682-5511
    "The most technologically advanced hard disk recovery software solutions is the "RECOVER Floppy Pro v1.0". It does everything for you automatically and ..."fugwachild.com
    C
    3 Street, Sidney, BC V8L 3A2‎ - (250) 655-1766
    "We are also a leading software provider for the IBM i marketplace with our partner Business Computer Design (BCD) Int'l Inc. Call us today to discuss ..."excelsystems.com
    D

    4401 Still Creek Drive #300, Vancouver, BC V5C 6G9‎ - (604) 299-5626
    Category: Services - Software Development
    "An Online Software Engineer works closely with our existing Online team, who are responsible for all online backend technology and the overall ..."gamasutra.com
    E
    West Georgia Street, Vancouver, BC V6E 3V7‎ - (604) 683-9200
    "C/C++, DirectX, PhysX, Actionscript, C#, Visual Basic, HLSL, Dark Basic, HTML, Javascript. Software Aptitudes: Visual Studio, Flash, Maya, Photoshop ..."ourstudentportfolios.com
    F

    1275 West 6th Avenue, Vancouver, BC V6H 1A6‎ - (604) 676-1086
    "SDA Software Associates is a full-service software development and consulting firm located in Vancouver. We are software developers, passionate about ..."bctia.org
    G
    West Georgia Street, Vancouver, BC V6C 3E8‎ - (604) 689-7842
    "Software: Best Way to Save on Taxes. Getting the global view: Nestle, led by Peter Brabeck-Letmathe, climbs to the #1 spot in this year's Best ..."findarticles.com
    H
    West Georgia Street, Vancouver, BC V6E 3V7‎ - (604) 684-5344
    Category: Computer Software
    "Name: Microsofot Corportation (I) Pvt. Ltd Address: 7th Floor, Tower B, DLF, DLF Cyber City Ph-III, Gurgaon, Haryana 122001, India Phone: +91 124 4158999 ..."microsoft.com
    I
    Abbott Street, Vancouver, BC V6B 2K7‎ - (604) 685-9287
    "Symbian: You can develop PhoneGap apps for Symbian without any external software, using Nokia's Web Runtime (WRT). However, Aptana Studio and the ..."avimba.com
    J

    13061 96A Avenue, Surrey, BC V3T 5N3‎ - (604) 630-4292
    "Mr. Roshan Shah development of the software did not function as specified in the work activity sheet. The Seller promised me that he would fix the ..."ripoffreport.com


    Look at Adagio Accounting.
    Great financials, room to grow.
    www.AccsysSolutions.com
    British Columbia
    Abbott Street, Vancouver, BC V6B 2K4‎ - (604) 639-9990
    Category: Computer Software
    "Wavemakers Inc. is a leading developer of processors and software algorithms which optimize voice quality and speech recognition in automotive ..."mmvf.com
    B

    c/o Serebra Learning Corporation, 600-1188 West Georgia Street, Vancouver, BC V6E 4A2‎ - (604) 676-5480
    "Microsoft Visual C++ 6.0: Designing and Implementing Applications - Part 4 Course Outline - NGE72613 - Microsoft Visual C++ 6.0: Designing and ..."training-classes.com
    C
    East Keith Road, North Vancouver, BC V7J 1J3‎ - (604) 983-3389
    Category: Computer Software
    "604-986-2643 604-637-8747 steve@scoopconsulting.ca www.scoopconsulting.ca SDA Software Associates Inc 1275 6th Ave W Suite 300, Vancouver V6H 1A6 Sasa ..."issuu.com
    D

    3264 Beta Avenue, Burnaby, BC V5G 4K4‎ - (800) 661-1885
    "They will learn programming tools such as Perl, C++, C-shell, Mel scripting, MaxScript, DirectX & OpenGL. Students in this program will become very ..."askedu.net
    E
    West 8th Avenue, Vancouver, BC V6J 5C6‎ - (604) 733-2996
    "This course is designed for those who are already familiar with the VDDT software – either through the Introduction to VDDT course, or through previous ..."essa.com
    F
    14098 Coldicutt Avenue, White Rock, BC V4B 3B4‎ - (778) 834-7682
    Category: Services - Software Development
    "Virus detection and protection; Adware deletion; Software training; Website design, hosting and updates; Database design; Custom programming (C++, C#, . ..."rickrova.com
    G
    Squamish, BC‎ - (800) 604-3282
    "Miva Merchant SecureNetShop Payer Cardinal Commerce – A software authentication platform Authentication that supports Verified by Visa and MasterCard ..."docstoc.com
    H
    Henning Drive, Burnaby, BC V5C 6P8‎ - (604) 299-2385
    "Candidates must able to establish, operate and maintain local and wide area networks (LANs and WANs) on hardware, software, peripheral and cabling. ..."3dimension.com
    I
    46 Wilkes Creek Drive, Port Moody, BC V3H 1T9‎ - (604) 782-9944
    "Our expert team of software developers and experience designers can breed your ideas into reality! Discover the possibilities with a free consultation ..."synues.com
    J
    King George Highway, Surrey, BC V3T 2V1‎ - (604) 589-0037
    "Reto Baettig: "newbie question: tcp/ip in kernel; Kurt Garloff: "Software Suspend v7a; Tigran Aivazian: "Re: How does the kernel map physical to virtual ..."indiana.edu
    A.
    Wavemakers Inc
    Abbott Street, Vancouver, BC V6B 2K4‎ - (604) 639-9990
    B.
    Serebra Connect

    c/o Serebra Learning Corporation, 600-1188 West Georgia Street, Vancouver, BC V6E 4A2‎ - (604) 676-5480
    C.
    Softrend Systems Inc
    East Keith Road, North Vancouver, BC V7J 1J3‎ - (604) 983-3389
    D.
    Art Institute Of Vancouver The

    3264 Beta Avenue, Burnaby, BC V5G 4K4‎ - (800) 661-1885
    E.
    Essa Technologies Ltd
    West 8th Avenue, Vancouver, BC V6J 5C6‎ - (604) 733-2996
    F.
    Rick Rova Computer Services
    14098 Coldicutt Avenue, White Rock, BC V4B 3B4‎ - (778) 834-7682
    G.
    Paradata Systems Inc
    Squamish, BC‎ - (800) 604-3282
    H.
    Nicer Technology
    Henning Drive, Burnaby, BC V5C 6P8‎ - (604) 299-2385
    I.
    Synues Interactive
    46 Wilkes Creek Drive, Port Moody, BC V3H 1T9‎ - (604) 782-9944
    J.
    Wizard IT Services
    King George Highway, Surrey, BC V3T 2V1‎ - (604) 589-0037

    A
    Burrard Street, Vancouver, BC V6C 3P6‎ - (604) 689-4345
    "C#, C++, JAVA, XML/SOAP; SQL Server 2000, Oracle 10i; MFC, .Net, Web Services. (Ensure your skills/expertise matches what you excel at and what ..."cadman.ca
    B
    Hamilton Street, Vancouver, BC V6B 2S2‎ - (604) 282-4360
    "We cater to a broad array of proprietary software development needs. We are dedicated, long-term IT partners of our clients; as we help them realize ..."captustech.com
    C
    Vancouver, BC‎ - (604) 682-5539
    "Our clients require expertise over a broad spectrum from C++, Java, Oracle and SQL to firmware, RF, and DSP design. Their infrastructure generally ..."thinkjsa.com
    D
    Burrard Street, Vancouver, BC V6C 2B5‎ - (604) 688-8946
    "Stretchware.com - Stretch Ware - Ergonomic software that reminds you to stretch by doing stretching exercises to help prevent stiff joints, muscles ..."domaintools.com
    E
    Cliveden Avenue, Delta, BC V3M 6T2‎ - (604) 540-3971
    "115 an hour. C++ programmer. Contracts lined up till next year! That's surprising. Software engineers/programmers are like a dime a dozen ..."discovervancouver.com
    F
    32 Avenue, Langley, BC V2Z 2C8‎ - (604) 534-0722
    "DISAM Software Development Kit license for all 32bit and 64bit Operating System platforms. Please note: The 32/64bit version of DISAM is required for ..."isam.ca
    G
    (604) 222-1047
    "Colaberated with Misha Kopcakov at the Institute of Nuclear Research in Moscow to bring their mailers and other Internet software into synch after ..."davidcunningham.ca
    H

    (778) 782-3098
    "What are SofTel's advantages over other VOIP Software There are a few key advantages of using SFU SofTel over other free VoIP services: • there are ..."docstoc.com
    I
    West Broadway, Vancouver, BC V5Z 1K5‎ - (604) 606-8070
    "Software - We sell web-based tools for scenario decision support. We will sell software licenses, or we will host scenario modeling environments ..."facet.com
    J
    Granville Street, Vancouver, BC V6C 3J3‎ - (604) 687-5919
    "Principal engineer / senior software engineer Resume. CNC Global Vancouver, B.C. (604) 687-5919. October 1997 to - contract position. March 1998 ..."devbistro.com

    90 Day 100% Money Back Guarantee
    Expert on-site IT Service & Support
    www.Blueprof.ca
    Blueprof Consulting Inc., 999 W. Broadway, Suite 720, Vancouver, BC
    Marineview Crescent, North Vancouver, BC V7R 3P5‎ - (604) 986-0936
    "are interested in helping us develop our diagnostic capabilities and enhance our exisiting software. We would be looking for programmers with C++ ..."dsaint.com
    B
    301-2975 Princess Crescent, Coquitlam, BC V3B 7N3‎ - (604) 468-7297
    "JavaScript syntax is based on the popular programming languages C, C++, and Java, which makes it familiar and easy to learn for experienced programmers. ..."canyonsprings.ca
    C

    5993 Longdin Road, Ferndale, WA, United States‎ - (866) 354-3480
    "This software is a one time application. Once you or the Tech member close the connection the application is totally removed from memory and no ..."wisenetworks.net
    D
    Glenhurst Street, Maple Ridge, BC V2X 0B9‎ - (604) 836-1522
    "Automation engineering and service, custom electronics design and prototyping, and custom software applications design in C/C++, Visual Basic, Flash ..."axxon.ca
    E
    West 10 Avenue, Vancouver, BC V6H 1J7‎ - (604) 734-2796
    "Our payroll software is private-labeled for the Microsoft Dynamics AX suite. LTS LeaderBoard Corp 2591 Panorama Dr PO Box 21043, Coquitlam V3E 2Y0 Gerry ..."issuu.com
    F
    West Hastings Street, Vancouver, BC V6B 1L1‎ - (604) 215-1556
    "Basic Knowledge: Maya, C++ Credit List: The Simpsons, Seasons 18-20: TV Series; Background Layout The Simpsons Movie: Feature Film; Layout ..."loriz.ca

    PCTech Computer Repair Services
    See My Profile
    YellowPages.ca/PCTechComputerRepair
    PCTech Computer Repair Services, 4129 Fraser Street, Vancouver, BC