Module 1
Module 1
Fundamentals of computations
Hardware Software
Fundamentals of computations
Computers generally operate in a 2 step cycle
CODE developed by the humans are in text from and not binary. So, to process
these instructions, text CODE must be converted into the binary form.
1. Compiling
2. Interpreting
Fundamentals of computations
Compilation: It is the process of converting text CODE into machine code. Here, entire
set of instruction are first converted into machine code. This can later be executed to
achieve the desired result.
Example: C/C++
Example: Python
Compiled CODEs are generally faster. However, they have platform dependence of the
generate machine code.
Interpreter CODEs are generally more flexible and dynamic, but are usually slower.
Fundamentals of computations
A programming language generally has following components
1. Data type: Object defined in the program will have some basic characteristic
Example: Arrays.
4. Assignments: It is a statement that sets and/or re-sets the value stored in the variable
Example: a=3+1.
Fundamentals of computations
5. Function: It is a command that accomplish a specific task. It generally takes an
argument and return a value
6. Control structure: Control structures are specific commands that dictate which
part of the program the computer will executed next.
Example: If command
Data visualization
Data
Information
Line chart
Pie chart
Log plot
Data visualization
Line chart
Pie Chart
Scatter plots
It involves taking the result of data analysis, making inferences on the relations
studied, and using them to conclude.
Qualitative data can take on numerical values, but those numbers have little
mathematical meaning.
1. Nominal data: This is a type of data used to name variables without providing any
numerical value.
2. Ordinal data: This is a data type with a set order or scale to it. However, this order
does not have a standard scale on which the difference in variables in each scale is
measured.
Data interpretation
Qualitative methods
Qualitative data analyzed graphically using a bar chart and pie chart.
In most of the cases, qualitative data has to be converted into numerical data before
the processing. However, these values do not exhibit quantitative characteristics.
Arithmetic operations can not be performed on them.
Data interpretation
Quantitative methods
Quantitative data, also known as numerical data, is always collected in number form.
1. Discrete Data: This is data type that represents countable items. It take on values that
can be grouped into a list.
2. Continuous Data: It represents a data type that can assume any value. Continuous
Data represents measurements and therefore their values can't be counted but they can
be measured.
Continuous data can further be divided into two catagories: (a) Interval data, and (b)
ratio data
Data interpretation
Quantitative methods
a. Interval data: This is a data type measured along a scale, in which each point is
placed at an equal distance from one another.
b. Ratio data: This data type has same properties as interval data, with an equal and
definitive ratio between each data and absolute “zero” being treated as a point of
origin. Thus, there can be no negative numerical value in ratio data.
Quantitative data may be visualized in different ways depending on the type of data
being investigated, e.g., histogram, scattered plot, or line plot etc.
Note: One of the key factor that influence a data is bias. Presence of nay bias may
lead to falsification of results. Thus it important to avoid bias during the data
collection and interpretation.
Data fitting and (inter-extra)polation
Interpolation or extrapolation is a type of
estimation, a method of constructing
new data points within the range of a
discrete set of known data points.
To interpolate/extrapolate, we require a
function that is most suitable to
represent the given data set.
Function required for the interpolation is obtained via the curve fitting.
y= f(x)
Linear fitting
x = [1,2,3,4]
y = [1,2,3,4]
plt.plot(x, y)
plt.show()
Data plotting - Python
import matplotlib.pyplot as plt
x = [1,2,3,4]
y = [1,2,3,4]
plt.plot(x, y)
plt.xlabel('x - axis')
plt.ylabel('y - axis')
plt.show()
Data plotting - Python
import matplotlib.pyplot as plt
x = [1,2,3,4]
y = [1,2,3,4]
plt.plot(x, y)
plt.xlabel('x – axis')
plt.ylabel('y – axis')
plt.show()
Data plotting - Python
import matplotlib.pyplot as plt
x = [1,2,3,4]
y = [1,2,3,4]
plt.plot(x, y, color='green', linestyle='dashed', linewidth = 3,
marker='o', markerfacecolor='blue', markersize=12)
plt.xlabel('x – axis')
plt.ylabel('y – axis')
plt.title('My first graph')
plt.show()
Data plotting - Python
import matplotlib.pyplot as plt
x1 = [1,2,3,4]
y1 = [1,2,3,4]
plt.plot(x1, y1)
x2 = [1,2,3,4]
y2 = [4,3,2,1]
plt.plot(x2,y2)
plt.xlabel('x – axis', fontsize=16)
plt.ylabel('y – axis', fontsize=16)
plt.title('Two lines on same graph!')
plt.show()
Data plotting - Python
import matplotlib.pyplot as plt
plt.title('Two lines on same graph!')
x1 = [1,2,3,4]
plt.legend()
y1 = [1,2,3,4]
plt.show()
plt.plot(x1, y1, label = "line 1")
x2 = [1,2,3,4]
y2 = [4,3,2,1]
plt.plot(x2,y2, label = "line 2")
plt.xlabel('x – axis')
plt.ylabel('y – axis')
Data plotting - Python
import matplotlib.pyplot as plt
import numpy as np
y = [1,2,3,4]
plt.show()
Data plotting - Python
import matplotlib.pyplot as plt
Import numpy as np
y1 = [1,2,3,4]
y2 = [1,2,3,4]
tick_label = ['one', 'two', 'three', 'four']
plt.bar(np.arange(len(y1))-0.2,y1,tick_label = tick_label, width=0.4)
plt.bar(np.arange(len(y2))+0.2,y2,tick_label = tick_label, width=0.4)
plt.title('my bar chart')
plt.legend(labels=['a','b'])
plt.show()
Data ploting - Python
import matplotlib.pyplot as plt
ages =[2,5,70,40,30,45,50,45,43,40,44,60,7,13,57,18,90,77,32,21,20,40]
range = (0, 100)
bins = 10
plt.hist(ages, bins, range)
plt.xlabel('age')
plt.ylabel('# of people')
plt.title('My histogram')
plt.show()
Data ploting - Python
import matplotlib.pyplot as plt
ages =[2,5,70,40,30,45,50,45,43,40,44,60,7,13,57,18,90,77,32,21,20,40]
range = (0, 100)
bins = 10
plt.hist(ages, bins, range, edgecolor='black')
plt.xlabel('age')
plt.ylabel('# of people')
plt.title('My histogram')
plt.show()
Data ploting - Python
import matplotlib.pyplot as plt
slices = [3, 7, 8, 6]
plt.show()
Data ploting - Python
import matplotlib.pyplot as plt
slices = [3, 7, 8, 6]
plt.show()
Data ploting - Python
import matplotlib.pyplot as plt
Import numpy as np
x = [1,2,3,4,5,6,7,8,9,10]
y = [2,4,5,7,6,8,9,11,12,12]
plt.scatter(x, y)
plt.xlabel('x – axis')
plt.ylabel('y – axis')
plt.title('scatter plot')
plt.xticks(np.arange(min(x), max(x),1.0))
plt.show()
Data ploting - Python
import matplotlib.pyplot as plt
import numpy as np
Z = X ** 2 + Y ** 2
plt.contourf(X,Y,Z)
plt.show()
Data ploting - Python
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits import mplot3d
plt.axes(projection="3d")
x=[1,2,3,4,5]
y=[3,5,2,1,4]
z=[5,2,1,4,3]
plt.plot(x,y,z)
plt.show()