Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
8 views5 pages

APP Lab Expt 4

The document outlines a process for calculating the mean and standard deviation of a dataset using numpy, followed by generating a probability density function (pdf) and plotting the results. It also includes tasks related to matrix operations, such as creating random matrices, performing arithmetic operations on matrices, and solving systems of linear equations. Additionally, it mentions using scipy and pyplot for statistical analysis and data visualization.

Uploaded by

prabhakarele8
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)
8 views5 pages

APP Lab Expt 4

The document outlines a process for calculating the mean and standard deviation of a dataset using numpy, followed by generating a probability density function (pdf) and plotting the results. It also includes tasks related to matrix operations, such as creating random matrices, performing arithmetic operations on matrices, and solving systems of linear equations. Additionally, it mentions using scipy and pyplot for statistical analysis and data visualization.

Uploaded by

prabhakarele8
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/ 5

#Calculate mean and Standard deviation.

mean = np.mean(x)
sd = np.std(x)
print("mean is : ",mean)
print("standard deviation is : ",sd)
#Apply function to the data.
pdf = normal_dist(x,mean,sd)
print("pdf is : ",pdf)

#Plotting the Results


plt.plot(x,pdf , color = 'red')
plt.xlabel('Data points')
plt.ylabel('Probability Density')
plt.show()

output:

mean is : 10.5
standard deviation is : 5.59564334905254
pdf is : [ 4.16011092 4.66826665 5.21339885 5.79429765 6.40907276 7.05511596
7.72907751 8.42685887 9.14362342 9.87382657 10.61126621 11.3491537
12.08020482 12.79674954 13.49085873 14.15448497 14.77961431 15.35842504
15.88344912 16.34773173 16.74498415 17.06972528 17.31740742 17.48452225
17.56868344 17.56868344 17.48452225 17.31740742 17.06972528 16.74498415
16.34773173 15.88344912 15.35842504 14.77961431 14.15448497 13.49085873
12.79674954 12.08020482 11.3491537 10.61126621 9.87382657 9.14362342
8.42685887 7.72907751 7.05511596 6.40907276 5.79429765 5.21339885
4.66826665 4.16011092]

4. The package numpy

a) Creating a matrix of given order m x n containing random numbers in the range 1 to 99999
Program:

Outpu:

b) Write a program that adds, subtracts and multiplies two matrices. Provide an interface such that, based on the prompt,
the function (addition, subtraction, multiplication) should be performed

Program:
Output:
c) Write a program to solve a system of n linear equations in n variables using matrix inverse

Program:
(Or)

Output:

5. The package scipy and pyplot


a) Finding if two sets of data have the same mean value
program:
from numpy import mean

arr1 = [[1, 3, 27],


[3, 4, 6],
[7, 6, 3],
[3, 6, 8]]
print("Arithmetic Mean is :", mean(arr1))
arr2 = [[1, 3, 27],
[3, 0, 6],
[7, 6, 4],
[8, 6, 8]]

You might also like