Types of Sampling

Any plan that relies on random selection is called a probability sampling plan (or technique). The following three probability sampling plans are among the most commonly used.

  1. Simple random sampling
  2. Cluster Sampling
  3. Stratified Sampling
1. Simple Random Sampling
        As the name suggests, the simplest probability sampling plan. It is equivalent to "selecting ball out of a bag". Each individual has the same chance of being selected.

2. Cluster Sampling
        This sampling technique is used when the population is naturally divided into groups (also known as a cluster). For example, all the students in a university are divided into majors, all the bank accounts are divided into a bank branch, all the registered voters are divided into election districts.
        In cluster sampling, we take a random sample of clusters and use all the individuals within the selected clusters as our sample. For example, in order to get a sample of the bank account whose bank account branch belongs to a certain city, you choose 5 branches at random from among all the branches in that city and use all the account in 5 selected branches as your sample.

3. Stratified Sampling
        Stratified sampling is used when the population is divided into sub-population which we can stratum (plural strata). For example, all the students in a certain college are divided by gender or by year in college. In stratified sampling, we choose a simple random sample from each stratum, and our sample consists of all these simple random samples put together. For example, in order to get a random sample of the bank account whose account belong to a certain city, we choose a random sample of 50 accounts from each branch present in that city our sample consists of all these samples put together.

Components of AI

AI is a vast field for research and it has got applications in almost all possible domain. By keeping this in mind, research in AI has focussed mainly on the following components of AI:
  1. Learning
  2. Reasoning
  3. Problem Solving
  4. Perception
  5. Knowledge representation
  6. Language understanding.
1. Learning
        Learning is a very essential part of AI and it happens in a number of different forms. The simplest form of learning is by trial and error. In this form, the program remembers the section that has given the desired output and discards the other trial actions and learns by itself. For example, in chess (program) mate-in-one chess problems might try out moves at random until one is found that achieves mate. Here the program remembers the successful move and next time the computer is given the same problem it is able to produce the result instantly. It is also called unsupervised learning. The simple learning of individual items - solutions to problems, worlds of vocabulary, etc. is known as rote learning. In the case of rote learning, the program simply remembers the problem solution pairs or individual items. In other cases, a solution to few of the problems is given as input to the system, the basis on which the system or program needs to generate solutions for new problems. This is known as supervised learning.

2. Reasoning
        Reasoning is also called as logic or generating judgments from the given set of facts. The reasoning is carried out based on a strict rule of validity to perform a specified task. Reasoning can be of two types, deductive or inductive. The deductive reasoning is in which the truth of the premised guarantees the truth of the conclusion while, in case of inductive reasoning, the truth of the premises supports the conclusion but it cannot be fully dependent on the premises. In programming logic generally, deductive inferences are used. Reasoning involves drawing inferences that are relevant to the given problem or situation.

3. Problem Solving
        AI addresses a huge variety of problems. For example, finding out winning moves on the board games, planning actions in order to achieve the defined task, identifying various objects from given images, etc. Problem-solving methods are mainly divided into two types special-purpose and general-purpose methods. General purpose methods are applicable to a wide range of problems one used in AI is means-end analysis, which involves the step-by-step reduction of the difference between the current state and the goal state. Special purpose methods are customized to solve a particular type of problems.

4. Perception
        In order to work in the environment, intelligent agents need to scan the environment and the various objects in it by means of different sense-organs, real or artificial. Agent scans the environment using sense organs like camera, temperature sensor, etc. This is called perception. After capturing various scenes, perceiver analyses the different objects in it and extracts their features and relationships among them.

5. Knowledge representation
        The information obtained from the environment through sensors may not be in the format required by the system. Hence, it needs to be represented in standard formats for further processing like learning various patterns, deducing inference, comparing with past objects, etc. There are various knowledge representation techniques like Prepositional logic and First-order logic.

6. Language understanding
        Natural Language Processing, involves machines or robots to understand and process the language that human speaks, and infer knowledge from the speech input. It also involves the active participation from a machine in the form of dialog i.e. NLP aims at the text or verbal output from the machine or robot. The input and output of an NLP system can be speech and written text respectively.

Error recovery techniques used by compiler

The error recovery techniques used by the compiler are as follows:
  1. Panic Mode Recovery
    1. This is the simplest method to implement and can be used by most parsing methods.
    2. On discovering an error, the parser discards the input symbol one at a time. until one of the designated set of synchronizing token is found.
    3. The synchronizing tokens are usually delimiters, such as semicolon or end, whose role in the source program is clear.
  2. Phrase-Level Recovery
    1. On discovering an error, a parser may perform local correction on the remaining input, that is it may replace a prefix of the remaining input by some string that allows the parser to continue.
    2. A typical local correction would be to replace a comma by a semicolon, delete an extraneous semicolon or insert a missing semicolon.
    3. It is implemented by filling in the blank entries with the pointers to error routines.
    4. These routines may,
      • change, insert or delete symbols on the input.
      • pop from the stack, and issue appropriate error messages.
  3. Error Productions
    1. If we have a good idea that the common errors that might be encountered, we can augment the grammar for the language at hand with productions that generate the erroneous constructs.
    2. We then use the grammar augmented by these errors productions to construct a parser.
    3. If an error production is used by the parser, we can generate appropriate diagnostics to indicate the erroneous construct that has been recognized in the input.
  4. Global Corrections
    1. In this compiler will make few changes (insertions, deletions, and changes of tokens) as possible in processing an incorrect input string.

Confusion and Diffusion

    The terms confusion and diffusion were introduced by Claude Shannon to capture the two basic building blocks for any cryptographic system. Shannon's concern was to thwart cryptanalysis based on statistical analysis. Shannon suggests two methods for frustrating statistical cryptanalysis, diffusion, and confusion.
  1.  Diffusion
  2.     It means any of the characters in plaintext is changed then simultaneously several characters of the ciphertext should also be changed. Similarly, if the character of ciphertext is changed then simultaneously several characters of plaintext should be changed. It is a classical transposition cipher.
    An example of diffusion is to encrypt a message M = m1,m2,m3,... of characters with an average operation.
    y(n)=(i=1kmn+i)
    adding k successive letters to get ciphertext letters yn.
    "Diffusion" = Transposition or Permutation
    For eg, Hill cipher has the characteristic of diffusion.

  3. Confusion
    1. Confusion seeks to make the relationship between the statistics of the ciphertext and the value of the encryption key as complex as possible, again to thwart attempts to discover the key.
    2. Thus, even if the attacker can get some handle on the statistics of the ciphertext, the ways in which the key was used to produce that ciphertext is so complex as to make it difficult to deduce the key. This is achieved by use of a complex substitution algorithm. 
    3. For eg., suppose we have a Hill cipher with a matrix nxn and suppose we have a plaintext-ciphertext pair of length n2 with which we are able to solve for the encryption matrix. If we change one character of the ciphertext, one column of the matrix can change completely. Of course, it would be more desirable to have the entire key change. When a situation like that happened, the cryptanalyst would probably need to solve for the entire key simultaneously, rather than piece by piece.

Diffie-Hellman Key Exchange Algorithm


  • The Diffie-Hellman algorithm is widely known as key exchange algorithm or key agreement algorithm developed by Whitfield Diffie and Martin Hellman in 1976. Diffie-Hellman is used to generate same (symmetric) private cryptographic key at sender as well as a receiver and so that there is no need to transfer this key from sender to receiver.
  • Remember that Diffie-Hellman algorithm is used only for a key agreement, not for encryption or decryption of the message. If sender and receiver want to communicate with each other they first agree on the same key generated by a Diffie-Hellman algorithm, later on, they can use this key for encryption or decryption.
Steps for Diffie-Hellman Algorithm:
  1. If A wants to communicate with B, they first must agree on two large prime numbers p and q (q < p).
  2. A selects another secret large random integer number XA, and calculate YA such that 
  3. YA = qXAmod p
  4. A sends this YA to B.
  5. B independently selects another secret large random integer number XB, and calculate YB such that,
  6. YB = qXBmod p
  7. B sends this number YB to A.
  8. Now, A is calculating his secret key by using,
  9. AK = (YB)XAmod p
  10. Similarly, B calculates his secret key YK by using,
  11. BK = (YA)XBmod p
  12. If AK = BK, then A and B can agree for future communication called as key agreement algorithm.
Fig. Diffie-Hellman Key exchange algorithm

Define the goals of security and specify mechanisms to achieve each goal.

    Information security consists of methods used to protect data or information being transmitted for preserving the integrity, confidentiality, and availability of the information.

  1. Confidentiality
  2.     Confidentiality is the protection of transmitted data from passive attacks. The two important concepts are:
    1. Data Confidentiality: Assures that private or confidential information is not disclosed to the unauthorized user.
    2. Privacy: Assures that individual control information related to them.
  3. Integrity
  4.     Integrity assures that messages are received as sent with no duplication, insertion, modification, reordering or replays. The two important concepts are:
    1. Data Integrity: Assures information is changed only in an authorized manner.
    2. System integrity: Assures that the system performs intended function property and free from unauthorized manipulation.
  5. Availability
  6.     Assures that system works correctly and service is available to authorized users.
These three concepts are termed as CIA triad and embody fundamental security objectives for data and information services.

State the condition for stability of LTI system and determine for the given discrete time system, h(n) = (0.3)^nu(n) + 5δ(n), is stable of not.

Condition for the stability of LTI system: LTI system is stable if its impulse response is absolutely summable i.e., finite.
k=|h(k)|<

h(n) = (0.3)nu(n) + 5δ(n)

k=
  [ (0.3)nu(n) + 5δ(n) ]
Since, u(n) = 1 n ≥0
                  = 0 n < 0
also, δ(n) = 1 n = 0
                = 0 otherwise
Therefore, limits of u(n) will be from 0 to ∞ and limits for δ(n) will be only 0.

n=00.3nu(n)+5|δ(n)|





Since, u(n) = 1, between 0 to ∞ and δ(n)n=0 = 1
n=00.3nn=0(5)
= 5 + 0.30 + 0.31 + 0.32 +0.33 + ...
= 5 + 1 + 0.3 + 0.3 + 0.32 + 0.33 + ...
= 5 + 1 / (1 - 0.3)
= 5 + 1 / 0.7
= (3.5 + 1) / 0.7
= 4.5 / 0.7
= 45 / 7

k=|h(k)| = 45 / 7 

Therefore, the system is stable.