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

Python Numpy Assignment No 8

The document contains 11 NumPy programming problems involving finding minimum/maximum values, computing percentiles, means, standard deviations, covariances, correlations, and histograms of arrays. The problems require calculating various statistics along axes of multi-dimensional arrays and between multiple input arrays. Sample outputs showing the calculations on sample data are provided for each problem.

Uploaded by

Anni Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
206 views

Python Numpy Assignment No 8

The document contains 11 NumPy programming problems involving finding minimum/maximum values, computing percentiles, means, standard deviations, covariances, correlations, and histograms of arrays. The problems require calculating various statistics along axes of multi-dimensional arrays and between multiple input arrays. Sample outputs showing the calculations on sample data are provided for each problem.

Uploaded by

Anni Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

NUMPY ASSIGNMENT NO 8

1. Write a Python program to find the maximum and minimum value of a given flattened array. Expected
Output:
Original flattened array:
[[0 1]
[2 3]]
Maximum value of the above flattened array:
3
Minimum value of the above flattened array:
0
2. Write a NumPy program to get the minimum and maximum value of a given array along the second axis.
Expected Output:
Original array:
[[0 1]
[2 3]]
Maximum value along the second axis:
[1 3]
Minimum value along the second axis:
[0 2]
3. Write a NumPy program to calculate the difference between the maximum and the minimum values of a
given array along the second axis.
Expected Output:
Original array:
[[ 0 1 2 3 4 5]
[ 6 7 8 9 10 11]]
Difference between the maximum and the minimum values of the said array:
[5 5]
4. Write a NumPy program to compute the 80th percentile for all elements in a given array along the second
axis.
Expected Output:
Original array:
[1.0, 2.0, 3.0, 4.0]
Largest integer smaller or equal to the division of the inputs:
[ 0. 1. 2. 2.]
5. Write a NumPy program to compute the median of flattened given array.
Note: First array elements raised to powers from second array
Expected Output:
Original array:
[[ 0 1 2 3 4 5]
[ 6 7 8 9 10 11]]
Median of said array:
5.5
6. Write a NumPy program to compute the mean, standard deviation, and variance of a given array along the
second axis.
Sample output:
Original array:
[0 1 2 3 4 5]
Mean: 2.5
std: 1
variance: 2.9166666666666665
7. Write a NumPy program to compute the covariance matrix of two given arrays.
Sample Output:
Original array1:
[0 1 2]
Original array1:
[2 1 0]
Covariance matrix of the said arrays:
[[ 1. -1.]
[-1. 1.]]
8. Write a NumPy program to compute cross-correlation of two given arrays.
Sample Output:
Original array1:
[0 1 3]
Original array1:
[2 4 5]
Cross-correlation of the said arrays:
[[2.33333333 2.16666667]
[2.16666667 2.33333333]]
9. Write a NumPy program to compute pearson product-moment correlation coefficients of two given arrays.
Sample Output:
Original array1:
[0 1 3]
Original array1:
[2 4 5]
Pearson product-moment correlation coefficients of the said arrays:
[[1. 0.92857143]
[0.92857143 1. ]]
10. Write a Python program to count number of occurrences of each value in a given array of non-negative
integers. Go to the editor
Note: bincount() function count number of occurrences of each value in an array of non-negative integers in
the range of the array between the minimum and maximum values including the values that did not occur.
Sample Output:
Original array:
[0, 1, 6, 1, 4, 1, 2, 2, 7]
Number of occurrences of each value in array:
[1 3 2 0 1 0 1 1]
11. Write a NumPy program to compute the histogram of nums against the bins. Go to the editor
Sample Output:
nums: [0.5 0.7 1. 1.2 1.3 2.1]
bins: [0 1 2 3]
Result: (array([2, 3, 1], dtype=int64), array([0, 1, 2, 3]))

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy