Matlab as a Calculator

MATLAB stands for “Matrix Laboratory” and is an interactive, matrix-based system and fourth-generation programming language from Mathworks Inc., which is mathematics software. Matlab helps to perform statistical analysis and gives the user complete freedom to implement specific algorithms and perform complex custom-tailored operations.

Matlab has a command-driven approach. Commands with appropriate arguments are written after the Matlab command prompt >>. The Matlab program provides the user with a convenient environment for performing many types of calculations. This introduction to Matlab will help users understand its importance and variety of applications in different scientific fields.

Matlab as a Calculator

Matlab has three primary windows.

1) Command windows
2) Graphics Windows
3) Edit Windows used to write M-Files

The common way to operate Matlab is to enter commands in the command window.

Matlab as a Calculator

>> 55 – 16
ans = 39
>> ans + 11
ans =50

Matlab assigns the results ans whenever you do not explicitly assign the calculations to a chosen variable.

>> a = 4                   % assigns a scalar quantity to a
>> a                         % Prints the scalar quantity in command windows
>> a = 4                   % suppressed echo printing
>> a =4; A=6; x=1;  % multiple variable definition

Note: Matlab treats names as Case-Sensitive.

>> format long
>> pi
>> format short
>> pi
Matlab as Calculator

Learn R Programming Language

Measures of Central Tendency: A Comprehensive Guide

Question: What is a measure of central tendency and what are the common measures of central tendency? Also, when is the median preferred over the mean?

A measure of central tendency is the single numerical value considered most typical of the values of a quantitative variable.

The most common measure of central tendency is the mode (i.e., the most frequently occurring number)

The median (i.e., the middle point or fiftieth percentile), and the mean (i.e., the arithmetic average).

The median is preferred over the mean when the numbers are highly skewed (i.e., non-normally distributed).

Measures of Central Tendency

Since, measures of central tendency condense a bunch of information into a single, digestible value that represents the center of the data, this makes measures of central tendencies important for several reasons:

  • Summarizing data: Instead of listing every data point, one can use a central tendency measure to get a quick idea of what is typical in the data set.
  • Comparisons: By computing central tendency measures for different groups or datasets, one can easily compare them to see if there are any differences.
  • Decision making: Central tendency measures can help to make wise decisions. For instance, knowing the average income in an area can help set prices. Imagine an organization is analyzing customer purchases. Knowing the average amount spent can help them tailor promotions or target specific customer groups.
  • Identifying trends: Measures of central tendencies may help in observing the trend over time. This can be done by using different visualizations to see if there are any trends, like a rise in average house prices.

However, it is very important to understand these Measures of Central Tendency (mean, median, mode). Each measure of central tendency has its strengths and weaknesses. Choosing the right measure of central tendency depends on the kind of data and what one’s interest is to extract from and try to understand.

Statistics Help measures of central tendency

Read more about measures of Central Tendency

Online MCQs Test Preparation Website

R Frequently Asked Questions

Constructing Frequency Tables (2012)

A frequency table is a way of summarizing a set of data. It is a record of each value (or set of values) of the variable in the data/question. In this post, we will learn about the ways of Constructing Frequency Tables for discrete and continuous data.

A grouping of qualitative data into mutually exclusive classes showing the number of observations in each class is called a frequency table. The number of values falling in a particular category/class is called the frequency of that category/class denoted by $f$.

If data of continuous variables are arranged into different classes with their frequencies, then this is known as continuous frequency distribution. If data of discrete variables is arranged into different classes with their frequencies then it is known as discrete distribution or discontinuous distribution.

Discrete Frequency Distribution Table Example

Car TypeNumber of Cars
Local 50
Foreign 30
Total Cars

80

Constructing Frequency Tables

Constructing Frequency tables (distributions) may be done for both discrete and continuous variables. A discrete frequency distribution can be converted back to original values, but for continuous variables, it is not possible.

The following steps are taken into account while constructing frequency tables for continuous data.

  1. Calculate the range of the data. The range is the difference between the highest and smallest values of the given data.
    \[Range = Highest Value – Lowest Value\]
  2. Decide the number of Classes. The maximum number of classes may be determined by the formula
    Number of classes $C = 2^k$     OR    Number of classes $(C) = 1+3.3 log (n)$
    Note that: Too many classes or too few classes might not reveal the basic shape of the data set.
  3. Determine the Class Interval or Width
    The class all taken together should cover at least the distance from the lowest value in the data up to the highest value, which can be done by this formula \[I=\frac{Highest Value – Lowest Value}{Number of Classes}=\frac{H-L}{K}\]
    Where $I$ is the class interval, $H$ is the highest observed value, $L$ is the lowest observed value and $K$ is the number of classes.
    Generally, the class interval or width should be the same for all classes.
    In particular interval size is usually rounded up to some convenient number, such as a multiple of 10 or 100. Unequal class intervals present problems in graphically portraying the distribution and in doing some of the computations. Unequal class intervals may be necessary for certain situations such as to avoid a large number of empty or almost empty classes.
  4. Set the Individual Class Limits
    Class limits are the endpoints in the class interval. State clear class limits so that you can put each of the observations into one and only one category i.e. you must avoid overlapping or unclear class limits. Class intervals are usually rounded up to get a convenient class size, and cover a larger than necessary range.
    It is convenient to choose the endpoints of the class interval so that no observation falls on them. It can be obtained by expressing the endpoints to one more place of decimal than the observations themselves, i.e. limits are converted to class boundaries to achieve continuity in data.
  5. Tally the Observation into the Classes
  6. Count the Number of Items in each Class
    The number of observations in each class I called the class frequency. Note that totaling the frequencies in each class must equal the total number of observations. After following these steps, we have organized the data into a tabulation form which is called a frequency distribution, which can be used to summarize the pattern in the observation i.e., the concentration of the data.
Constructing Frequency Tables

Note: Arranging/organizing the data into a tabulation or frequency distribution results in a loss of detailed information as the individuality of observations vanishes i.e. in frequency distribution we cannot pinpoint the exact value, and we cannot tell the actual lowest and highest values of the data. However, the lower limit of the largest, class conveys some essentially the same meaning. So in constructing the frequency tables, the advantages of condensing the data into a more understandable and organized form are more than offset this disadvantage.

Further Reading

Frequency Distribution Tables

Learn R Programming Language

Pie Chart | Visual Display of Categorical Data

A pie chart is a way of summarizing a set of categorical data. It is a circle that is divided into segments/sectors. Each segment represents a particular category. The area of each segment is proportional to the number of cases in that category. It is a useful way of displaying the data where the division of a whole into parts needs to be presented. It can also be used to compare such divisions at different times.

Pie Chart

A pie chart is constructed by dividing the total angle of a circle of 360 degrees into different components. The angle A for each sector is obtained by the relation:

$$A=\frac{Component Part}{Total}\times 360$$

Each sector is shaded with different colors or marks so that they look separate from each other.

Pie Chart Example

Make an appropriate chart for the data available regarding the total production of urea fertilizer and its use on different crops. Let the total production of urea be about 200 thousand (kg) and its consumption for different crops wheat, sugarcane, maize, and lentils is 75, 80, 30, and 15 thousand (kg) respectively.

Solution:

The appropriate diagram seems to be a pie chart because we have to present a whole into 4 parts. To construct a pie chart, we calculate the proportionate arc of the circle, i.e.

CropsFertilizer (000 kg) Proportionate arc of the circle
Wheat 75  $\frac{75}{200}\times 360=135$
Sugarcane 80   $\frac{80}{200}\times 360=144$
Maize

30

$\frac{30}{200}\times 360=54$
Lentils 15   $\frac{15}{200}\times 360=27$
Total 200 360

Now draw a circle of an appropriate radius, and make the angles clockwise or anticlockwise with the help of a protractor or any other device. For wheat make an angle of 135 degrees, for sugarcane an angle of 44 degrees, for maize, an angle of 54 degrees, and for lentils, an angle of 27 degrees, hence the circular region is divided into 4 sectors. Now shade each of the sectors with different colors or marks so that they look different from each other. The pie chart of the above data is

Pie Chart

Online MCQs Test Preparation Website gmstat.com

Favourite Subjects Pie Chart Example
Favourite Subjects