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 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
The median is one of the three main measures of central tendency, alongside the mean and mode. It represents the middle value of an ordered dataset. It is a powerful and reliable summary statistic and widely used, especially in real-life scenarios where data is skewed or contains outliers. Unlike the mean, the median is not affected by extreme values, which makes it incredibly useful in various fields. For the formula of the median, read the post: formula of median and definition.
Table of Contents
When the Median is Preferred over the Mean
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).
Importance of Measures of Central Tendencies
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.
Real-Life Examples and Uses of Median
Income & Salaries: The Median is used to represent the average income of a population more accurately. It is because A few ultra-rich individuals can skew the mean income upward. The median gives a more realistic picture of what a typical person earns. Example: If most people earn around 60,000, but a few CEOs earn 55,000 while the mean income could be $95,000 — misleading!
Education (Test/ Exame Scores): The median can be used to summarize exam results or performance data. A few very low or very high scores can distort the mean. For example, if most students score between 70 and 90, but a few score 10 or 100, the measure of central tendency, the median score, gives a better sense of central performance.
Real Estate (Home Prices): Reporting the median home price is common in real estate. Why Median? It avoids distortion from a few very expensive or very cheap homes. For example, A city may have a median home price of 5 million.
Sports (Player Performance): To report median stats like race times, goals scored, or batting averages. To avoid skewed data from one amazing or terrible performance. For example, a runner’s median race time over 10 races can better reflect consistency.
Healthcare (Medical Test Results): Reporting the median wait time in hospitals or median survival time in clinical trials may be beneficial. This is because medical data often contains outliers or skewed distributions. For example, if most patients wait 30 minutes, but a few wait 5 hours, the measure of central tendency, the median wait time, might be 35 minutes, while the mean could be misleadingly high.
Customer Feedback (Review Rating): Median star rating for products or services. Filters out extremely negative or overly positive outliers. For example, if ratings are 1, 5, 5, 5, and 1, the mean is 3.4 but the median is 5, better reflecting the typical rating.
Transportation (Travel Times): Apps like Google Maps or Waze often use median travel times to reflect a more realistic average, ignoring rare traffic jams or super fast times. For example, the median commute time may be 25 minutes, even if a few people experience 60-minute delays.
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 .
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 Type
Number 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.
Calculate the range of the data. The range is the difference between the highest and smallest values of the given data.
Decide the number of Classes. The maximum number of classes may be determined by the formula Number of classes OR Number of classes Note that: Too many classes or too few classes might not reveal the basic shape of the data set.
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 Where is the class interval, is the highest observed value, is the lowest observed value and 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.
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.
Tally the Observation into the Classes
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.
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.