0% found this document useful (0 votes)
19 views

P and S Manual - II Year Aids STD

Uploaded by

aar55721
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

P and S Manual - II Year Aids STD

Uploaded by

aar55721
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Approved by AICTE, Affiliated to Anna University, Chennai.

ISO9001:2015CertifiedInstitution,Accredited by NBA(BME,CSE,ECE,EEE,IT&MECH)Accredited by NAAC. #42,


Avadi -Vel Tech Road, Avadi, Chennai- 600062,Tamil Nadu, India.

DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

231MA303/PROBABILITY AND STATISTICS-LAB INTEGRATED

NAME :

REGISTERNO :

ROLLNO :

BRANCH : B. Tech-Artificial Intelligence and Data

Science YEAR : II

SEMESTER : III

DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

Vision

 To promote centre of excellence through effectual Teaching and Learning, imparting the
contemporaryknowledgecentriceducationthroughinnovativeresearchinmultidisciplinaryfields.
Mission

 To impart quality technical skills through practicing, knowledge up dating in recent technology

and produce professionals with multidisciplinary and leadership skills.


 To promote innovative thinking for design and development of software products of varying
complexity with intelligence to fulfill the global standards and demands.
 To inculcate professional ethics among the graduates and to adapt the changing technologies
through lifelong learning.
Approved by AICTE, Affiliated to Anna University, Chennai.
ISO9001:2015 Certified Institution, Accredited by NBA(BME,CSE,ECE,EEE,IT&MECH)Accredited by NAAC.
#42, Avadi -Vel Tech Road, Avadi, Chennai- 600062,Tamil Nadu, India.

CERTIFICATE

Name…………………….……………………….................. Year:…………… Semester:…………...


Branch: B. TECH – ARTIFICIAL INTELLIGENCE AND DATA SCIENCE University Register
No………….............. College Roll No: Certified that this is the bonafide record of
Work done by the above student in the 231MA303/PROBABILITY AND STATISTICS- LAB
INTEGRATED during the academic year 2024-2025.

Signature of Course Incharge Signature of Head of the Department

Submitted for the End Semester Practical Examination held on ........................ at VELTECH
MULTITECH Dr. RANGARAJAN Dr. SAKUNTHALA ENGINEERING COLLEGE, No.42,
AVADI–VELTECH ROAD, AVADI, CHENNAI-600062.

Signature of Examiners

Internal Examiner:…………… External Examiner:………………

Date:………………
DEPARTMENTOFARTIFICIALINTELLIGENCEANDDATASCIENCE

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

PEOs PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)

Train the graduates with the potential of strong knowledge in the respective
PEO1 field and to create innovative multi disciplinary solutions for challenges in
the society

Groom the engineers to understand, analyze different nature of data and


PEO2 use Machine Learning techniques to develop software systems with
varying complexity for data intensive applications

To practice professionalism among the graduates and reflect good


PEO3 leadership skills with ethical standards and continued professional
development through lifelong learning.

PROGRAMME SPECIFIC OUT COMES (PSOs)

PSO’s PROGRAMME SPECIFIC OUT COMES (PSOs)

To impart theoretical knowledge in the respective field along with recent


PSO1 industrial tools and techniques to solve societal problems

Apply the core competency obtained in the field of Machine Learning for
PSO2 analysis, design and development of computing systems for multi-
disciplinary problems

Acquire knowledge in the field of intelligence, deep learning and


PSO3
develop software solutions for security and analytic so of large volume
of data.
DEPARTMENTOFARTIFICIALINTELLIGENCEANDDATASCIENCE

POs Programme Outcomes (POs)

Engineering Knowledge: Apply knowledge of mathematics, science, engineering


PO1 fundamentals and an Engineering Specialization to the solution of complex engineering
problems.
Problem Analysis: Identify, formulate, review research literature and analyze complex
PO2 engineering problems reaching substantiated conclusions using first principles of mathematics,
natural sciences, and engineering sciences.
Design / Development of solutions: Design solutions for complex engineering problems and
PO3 design system components or processes that meet specified needs with appropriate
Consideration for public health and safety, cultural, societal, and environmental considerations.

Conduct Investigations of Complex Problems: Use research-based knowledge and research


PO4 methods including design of experiments, analysis and interpretation of data, and synthesis of
the information to provide valid conclusions.
Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
PO5 engineering and IT tools including prediction and modeling to complex engineering activities
with an understanding of the limitations.
The Engineer and Society: Apply reasoning informed by the contextual knowledge to assess
PO6 Societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to
the professional engineering practice.
Environment and sustainability: Understand the impact of the professional engineering
PO7 solutions in societal and environmental contexts, and demonstrate the knowledge of, and need for
sustainable development.

Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
PO8 norms of the engineering practice.

Individual and team work: Function effectively as an individual, and as a member or leader in
PO9 diverse teams, and in multidisciplinary settings.

Communication: Communicate effectively on complex engineering activities with the


PO10 engineering community and with society at large, such as, being able to comprehend and write
effectivereportsanddesigndocumentation,makeeffectivepresentations,andgiveandreceive
Clear instructions.
Project Management and Finance: Demonstrate knowledge and understanding of the
PO11 engineering and management principles and apply these to one’s own work, as a member and
leader in a team, to manage projects and in multidisciplinary environments.

Life-long learning: Recognize the need for, and have the preparation and ability to engage in
PO12 independent and life-long learning in the broadest context of technological change.
COURSE OBJECTIVES:

The student should be made to:

 Provide the required mathematical support in real life problems and develop probabilistic models
which can be used in several areas of science and engineering.
 The students will have a fundamental knowledge of Theoretical distributions concepts.
 Understand the basic concepts of one and two dimensional random variable which are widely used in
IT fields.
 Compute the test of hypothesis and apply in various engineering fields.
 Apply the significance of advanced design of experimental in some important engineering
applications.

COURSE OUTCOMES:

At the end of the course, the student should be able to

Course
Outcomes CO Statements

CO1 Demonstrate and apply the basic probability axioms and concepts in their core areas.

CO2 Apply the concepts of probability distribution in an appropriate place of engineering.


Calculate the relationship of two dimensional and random variables using correlation
CO3 techniques and apply the concept of correlation and regression in real life situation.
CO4 Apply the concept of testing of hypothesis for small and large samples in real life problems.

CO5 Identify the classification of design of experiment in their respective fields.

Mapping CO's with PO's & PSO’s

Course
PSO1
PSO2
PSO3
PO10

PO11

PO12
PO1

PO2

PO3

PO4

PO5

PO6

PO7

PO8

PO9

Outcome

CO1 3 3 2 2 1 - - - - - - 1 1 - -

CO2 3 3 2 2 1 - - - - - - 1 1 - -

CO3 3 3 2 2 1 - - - - - - 1 1 - -

CO4 3 3 2 2 1 - - - - - - 1 1 - -
CO5 3 3 2 2 1 - - - - - - 1 1 - -

CO 3 3 2 2 1 - - - - - - 1 1 - -

1–Low 2–Medium 3–High


lOMoARcPSD|27848569

Table of Contents

S.NO DATE LISTOFEXPERIMENTS CO PAGE SIGN


MARKS
NO

PROBABILITYANDSTATISTICS-LABINTEGRATED

Given a dataset of the number of hours spent on


physical activity and corresponding body mass index
1 (BMI) values, write a MATLAB program to CO3
calculate the correlation coefficient between the two
variables. Interpret the result to determine if there is
a relationship between physical activity and BMI.

Perform the regression of x on y using


MATLAB, where the goal is to predict the CO3
2 values of x given y and visualize the
relationship with a best-fit line?

Write a code to calculate the correlation


coefficient between two sets of data using
3 CO3
MATLAB, and what does the correlation
coefficient tell us about the relationship
between the data sets?

Write a MATLAB program to calculate the


4 correlation coefficient and comment on CO3
whether studying more hours’ results in better
test scores.

5 Write a MATLAB code for Linear Regression CO3


(regression of line)

6 Write a MATLAB program to perform a one- CO5


way ANOVA

7 Write a MATLAB program to perform a two- CO5


way ANOVA
Write a MATLAB program to perform a
8 CO5
three-way ANOVA

9 Latin square design CO5


lOMoARcPSD|27848569

EXNO:1 Given a data set of the number of hours spent on physical


activity and corresponding body mass index (BMI) values,
write a MATLAB program to calculate the correlation
DATE: coefficient between the two variables. Interpret there sult
to determine if there is a relationship between physical
activity and BMI.

AIM:

To write a MATLAB program to calculate the correlation coefficient between the


two variables

PROCEDURE:

1. Input the Data:


Create two vectors: one for physical activity hours and one for
corresponding BMI values.
2. Check Lengths:
Ensure the lengths of both vectors are the same.
If the lengths do not match, display an error message.
3. Calculate Correlation:
4. Compute the correlation coefficient between the two vectors (activity hours
and BMI values).
5. Display Results:
6. Print the correlation coefficient.
7. Base do the value of the correlation coefficient:
a. If it is positive, print that there is a positive correlation.
b. If it is negative, print that there is a negative correlation.
c. If it is zero, print that there is no correlation.

PROGRAM:

%Define the data set

activity_hours = [1,2,3,4,5];%Hours spent on physical activity

bmi_values = [24,23,22,21,20];%Corresponding BMI values

% Check if the lengths of the two vectors match if

length (activity_hours) ~ = length (bmi_values)

error ('The number of activity hours and BMI values must be the same.');

end

%Calculate the correlation coefficient


lOMoARcPSD|27848569

correlation_coefficient=corr(activity_hours',bmi_values');%Transposetocolumn vectors

%Display the correlation coefficient

disp(['CorrelationCoefficient:',num2str(correlation_coefficient)]);

%Interpretation

if correlation_coefficient>0

disp('There is a positive correlation between physical activity hours and BMI.');

elseif correlation_coefficient < 0

disp('There is a negative correlation between physical activity hours and BMI.');

else

disp('There is no correlation between physical activity hours and BMI.');

end

OUTPUT:

RESULT:
lOMoARcPSD|27848569

9
EXNO:2 Perform the regression of x on y using MATLAB, where the
goal is to predict the values of x given y and visualize the
DATE: relationship with a best-fit line?

AIM:

To write a MATLAB code to perform the regression of x on y and predict the relationship.

PROCEDURE:

1. Input Data Points:


The user is prompted to input both yyy-values and xxx-values as vectors.
2. Check Data Consistency:
It checks if the lengths of the xxx-values and yyy-values match. If they don't, an
error is raised.
3. Calculate Regression Coefficients:
The function poly fit is used to compute the slope mmm and intercept bbb for the
regression equation x=my+bx=my+bx=my+b.
4. Extract and Display Coefficients:
5. The slope and intercept of the regression line are extracted and stored.
6. Generate Predicted x-Values:
7. Based on the line equation, predicted x-values are computed using polyval.
8. Plot the Data and Regression Line:
The original data points are plotted as a scatter plot, and the regression line is
plotted on top.
9. Display Slope and Intercept:
The slope and intercept values are displayed in the command window.

PROGRAM:

%Step1: Input data points from the user

y=input('Enter they-values as a vector(e.g.,[2.12.93.74.25.1]):');

x=input('Enter the x-values as a vector(e.g.,[12345]):');

% Step 2: Check if the lengths of x and y match if length(x)

~= length(y)

error('The number of x-values and y-values must be the same');

end
lOMoARcPSD|27848569

10
% Step 3: Calculate coefficients for regression of x on y: x = my + b coefficients =

polyfit(y, x, 1);% 1 means fitting a line

%Step4: Extract slope(m) and intercept(b)


slope = coefficients(1);

intercept = coefficients(2);

%Step5: Generate predicted x-values based on the line equation

x_pred = polyval(coefficients, y);

% Step 6: Plot the original data and the regression line figure;

scatter(y, x, 'b', 'filled'); % Original data points hold on;

plot(y,x_pred,'r-');%Regression line

xlabel('y');

ylabel('x');

title ('Line of Regression of x on y'); legend('Data

points', 'Regression line');

hold off;

% Step 7: Display slope and intercept

disp(['Slope (m): ', num2str(slope)]);

disp(['Intercept(b):',num2str(intercept)]);
lOMoARcPSD|27848569

11

OUTPUT:

RESULT:
lOMoARcPSD|27848569

12
EXNO:3 Write a code to calculate the correlation coefficient between
two sets of data using MATLAB, and what does the
correlation coefficient tell us about the relationship between
DATE: the data sets?

AIM:

To write a MATLAB code to calculate the correlation coefficient between


two sets of data.
.

PROCEDURE:

1. Define Data Sets:


Initialize the vectors x and y with pre defined data points.
2. Calculate Correlation Coefficient:
Use the corrcoef function to compute the correlation coefficient matrix for
xxx and yyy.
3. Display the Correlation Matrix:
Output the entire correlation matrix to the console.
4. Extract and Display the Correlation:
Display the correlation coefficient between x and y by accessing the appropriate matrix
element (r (1, 2)).

PROGRAM:

%Define the data sets

x = [12,14,22,29,33];

Y = [15,18,20,25,30];

%Calculate the correlation coefficient

r = corrcoef(x, y);

% Display the correlation matrix disp('Correlation

Coefficient Matrix:'); disp(r);

% Extract and display the correlation coefficient between x and y

disp('Correlation Coefficient between x and y:');

disp(r(1,2));
lOMoARcPSD|27848569

13

OUTPUT:

RESULT:
lOMoARcPSD|27848569

14
EXNO:4 Consider the following data representing the number of
study hours and the corresponding test scores of 6
students: Study_Hours = [2,4,6,8,10,12]
Test_Scores = [50,55,65,70,80,90]. Write a MATLAB program
DATE: to calculate the correlation coefficient and comment on
whether studying more hours’ results in better test scores.

AIM:

To write a MATLAB program to calculate the correlation coefficient and comment


on whether studying more hours results in better test scores.

PROCEDURE:

1. Check Data set Lengths:


Ensure the lengths of Study_Hours and Test_Scores match. If not, an error is
raised.
2. Calculate Correlation Coefficient:
Compute the correlation coefficient between the two data sets using corr.
3. Display Correlation:
Output the calculated correlation coefficient.
4. Interpret Correlation:
Based on the value of the correlation coefficient, interpret whether the
relationship is positive, negative, or non-existent.

PROGRAM:

%Data representing study hours and corresponding test scores

Study_Hours=[2,4,6,8,10,12];

Test_Scores =[50,55,65,70,80,90];

% Step1: Check if the lengths of the two data sets are equal if

length(Study_Hours) ~= length(Test_Scores)

error('The number of study hours and test scores must be the same');

End

%Step2: Calculate the correlation coefficient

correlation_coefficient=corr(Study_Hours',Test_Scores');

% Step3:Display the result


lOMoARcPSD|27848569

15
disp(['Correlation Coefficient:',num2str(correlation_coefficient)]);

%Step4: Interpretation of the correlation if

correlation_coefficient > 0

disp('There is a positive correlation, meaning studying more hours results in better test
scores.');

elseif correlation_coefficient<0

disp('There is a negative correlation, meaning studying more hours results in lower test
scores.');

else

disp('There is no correlation between study hours and test scores.');

end

OUTPUT:

RESULT:
lOMoARcPSD|27848569

16

EXNO:5 Write a MATLAB code for Linear Regression (regression of


line)
DATE:

AIM:

To write a MATLAB code for linear regression of line.

PROCEDURE:

1. Define the Data Points:


Set x as the independent variable and y as the dependent variable.
2. Check Data Lengths:
Ensure that x and y has the same number of elements. If not, raise an error.
3. Perform Linear Regression:
Use poly fit to compute the slope and intercept of the best-fitline for y versus x.
4. Plot and Display Results:
Plot the original data and the regression line. Also, display the calculated slope
and intercept.

PROGRAM:

%Step 1: Define the data points

x=[12345]; %Independent variable

y=[2.12.93.74.25.1]; %Dependent variable

% Step 2: Check if the lengths of x and y match

if length(x) ~= length(y)

error('The number of x-values and y-values must be the same');

end

%Step3: Perform linear regression(calculate slope and intercept)

coefficients = polyfit(x, y, 1);% 1 indicates fitting a line

% Step 4: Extract the slope (m) and intercept (b)

slope = coefficients(1);

intercept = coefficients(2);
lOMoARcPSD|27848569

17
% Step 5: Predict y-values based on the regression line

y_pred = polyval(coefficients, x);

% Step 6: Plot the original data and the regression line

figure;

scatter(x, y, 'b', 'filled'); % Original data points

hold on;

plot(x,y_pred,'r-'); %Regression line

xlabel('x');

ylabel('y');

title('Linear Regression: Best-Fit Line');

legend('Data points', 'Regression line');

hold off;

% Step 7: Display slope and intercept

disp(['Slope (m): ', num2str(slope)]);

disp(['Intercept(b):',num2str(intercept)]);

OUTPUT:

RESULT:
lOMoARcPSD|27848569

18

EXNO:6
Write a MATLAB code for One-Way Classification ANOVA.
DATE:

AIM:

To write a MATLAB code for One way classification ANOVA.

PROCEDURE:

1. Define Sample Data:


Input data for three groups (group1, group2, and group3).
2. Combine Data and Create Group Labels:
Concatenate the data from all groups into a single array and create a corresponding
array of group labels (1 for group1, 2 for group2, 3 for group3).
3. Perform One-Way ANOVA:
Use anova1 to perform one-way ANOVA on the combined data with the group
labels.
4. Display p-value and Perform Post-Hoc Test:
Display the p-value from the ANOVA test and use multi compare to perform post-
hoc pair wise comparisons (e.g.,Tukey’s HSD).

PROGRAM:

%Sampledata

group1 = [23,45, 21,42,30];%Data for group1

group2 = [37, 52,40,48,35];%Data for group2

group3 = [25,50,32,46,28];%Data for group3

%Combine the data in to a single array(1Dvector) data =

[group1, group2, group3];

%Create a group identifier for each data point

group_labels = [ones (1, length(group1)), 2 * ones(1, length(group2)), 3 * ones(1,length(group3))];

%Perform one-way ANOVA


lOMoARcPSD|27848569

19

[p,tbl,stats]=anova1 (data,group_labels);

%Display the p-value

disp('P-value:');

disp (p);

%If you want to perform post-hoc tests (like Tukey's HSD)

multcompare (stats);

OUTPUT:

RESULT:
lOMoARcPSD|27848569

20

EXNO:7
Write a MATLAB code for Two-Way Classification ANOVA.
DATE:

AIM:

To write a MATLAB code for two way classification ANOVA.

PROCEDURE:

1. Define Sample Data:


Create a matrix representing the data for two factors: treatment and gender. Rows
correspond to different treatments, and columns correspond to gender (e.g., male
and female).
2. Perform Two-Way ANOVA:
Use ANOVAs 2 to perform two-way ANOVA on the data. These condargument
(3) Specifies that there are three replicates per group.
3. Display ANOVA Table:
Output the ANOVA table(tbl)showing results for both factors(treatment and
gender).
4. Display p-values:
Output the p-values to determine the significance of the effects of treatment,
gender, and interaction between them.

PROGRAM:

%Sample data for two-way ANOVA

%Factor A: Treatment (1, 2)

%Factor B: Gender (1=Male,2=Female)

% Create a matrix of data

data = [

23, 45; 30, 36; 27,42;%Treatment1

30, 47; 28, 38; 34, 41;%Treatment2

];

%Perform two way ANOVA


lOMoARcPSD|27848569

21

[p,tbl, stats]=anova2(data,3);

% Display the ANOVA table

disp('ANOVA Table:');

disp(tbl);

%Display the p-values

disp('P-values:');

disp(p);

OUTPUT:

RESULT:
lOMoARcPSD|27848569

22

EXNO:8
Write a MATLAB code for Three-way classification ANOVA
DATE:

AIM:

To write a MATLAB code for three way classification ANOVA.

PROCEDURE:

1. Define Sample Data:


Create a matrix with data organized by three factors: treatment, gender, and age
group. The rows represent different combinations of these factors.
2. Reshape Data:
Convert the data into long format by reshaping the matrix into a single vector
(values).Also, create vectors for the factor levels( treatment, gender, and age group).
3. Prepare Data for ANOVA:
Combine their shaped data and factor vectors into a table suitable for three-
way ANOVA.
4. Perform Three-Way ANOVA:
Use ANOVA 3(or appropriate method) to perform the three-way ANOVA and
display the ANOVA table and p-values to assess the significance of each factor
and their interactions.

PROGRAM:

%Sample data for three – way ANOVA


%Factor A: Treatment (1,2)
%Factor B: Gender (1=Male,2=Female)
%Factor C: Age Group (1=Young,2=Middle-aged,3= Old)

% Creating sample data


% Rows: Treatment x Gender x Age Group data =
[
23,30,28;25,35,32;29,40,33;%Treatment1,Male
22,32,30;27,34,35;24,29,31;%Treatment1,Female
30,40,29;34,42,33;31,35,36;%Treatment2,Male
lOMoARcPSD|27848569

23
28,36,30;29,38,35;32,39,34%Treatment2,Female

];

%Reshaped at a into long format

values = data(:);
treatment = repmat([1; 2], 6, 1);% Treatment levels gender =
repmat([1; 2], 3*2, 1);% Gender levels age_group =
repmat((1:3)', 4, 1);% Age group levels

%Create a table for ANOVA


tbl=table(values, treatment, gender, age_ group);

% Perform three-way ANOVA


[p,tbl ANOVA]=anova3(data);
% Display the ANOVAtable
disp('ANOVATable:');
disp(tblANOVA);

%Display the p-values


disp('P-values:'); disp(p);

OUTPUT:

RESULT:
lOMoARcPSD|27848569

24

EXNO:9 Create a simple MATLAB program to generate a 3×3 Latin


square design for three treatments: A, B, and C. Simulate
experimental results for each treatment, then perform a one-
DATE: way ANOVA to determine if there is a significant difference
in the results between the treatments.

AIM:

To write a MATLAB code to generate Latin square design for three experiments A,
B, C. Also to perform one way ANOVA.

PROCEDURE:

1. Define Treatments and Latin Square:


Define the treatments (A, B, C) and create a3x3 Latin square matrix that assigns
treatments to experimental conditions.
2. Simulate Experimental Results:
Use nested loops to fill a matrix with simulated experimental results by adding a
random value to the treatment index.
3. Reshape Data for ANOVA:
Reshape the experimental results and their corresponding group labels into
column vectors for use in the one-way ANOVA.
4. Perform ANOVA and Display Results:
Perform one-way ANOVA using anova1and display the p-value. Interpret the p-
value to determine if there is a significant difference between treatments.

PROGRAM:

% Define treatments

treatments = {'A', 'B', 'C'};

% Generate a 3x3 Latin square

latin_square =

[1, 2, 3;

2,3,1;

3,1,2];

% Display the Latin square

disp('Latin Square Design:');

disp(treatments(latin_square));

% Create a matrix for simulated experimental results


lOMoARcPSD|27848569

25

data = zeros(3,3);

%Simulate experimental results for each treatment

for i = 1:3

forj=1:3

%Simulate data(random values for demonstration)

data(i, j) = rand() + latin_square(i, j);% Adding treatment index to random value

end

end

% Display the simulated experimental results

disp('Simulated Experimental Results:'); disp(data);

%Reshape the data for ANOVA

reshaped_data = reshape (data',[],1);%Reshape to column vector

group_labels=reshape(latin_square',[],1);%Grouplabelsfortreatments

%Perform one-way ANOVA

[p,tbl,stats]=anova1(reshaped_data,group_labels);

%Display p-value

disp(['p-value:',num2str(p)]);

%Ifp-valueislessthan0.05,there is a significant difference

if p < 0.05

disp('There is a significant difference between the treatments.'); else

disp('There is no significant difference between the treatments.'); end


lOMoARcPSD|27848569

26

OUTPUT:

RESULT:

You might also like