100% found this document useful (1 vote)
2K views5 pages

Import As From Import Import: Problem 1

The document contains 5 problems related to data analysis and probability distributions. The problems cover calculating statistical measures like mean, median, and mode from data, finding combinations and permutations of elements in an array, calculating probabilities using the binomial and Poisson distributions, and determining the number of ways dancers can be arranged on a dance floor. Code solutions are provided for each problem to calculate and return the requested values.

Uploaded by

ikhwancules46
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
100% found this document useful (1 vote)
2K views5 pages

Import As From Import Import: Problem 1

The document contains 5 problems related to data analysis and probability distributions. The problems cover calculating statistical measures like mean, median, and mode from data, finding combinations and permutations of elements in an array, calculating probabilities using the binomial and Poisson distributions, and determining the number of ways dancers can be arranged on a dance floor. Code solutions are provided for each problem to calculate and return the requested values.

Uploaded by

ikhwancules46
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

Problem 1

import numpy as np
from scipy import stats
import statistics

def measures(arr):
#Write your code here
'''
Input: arr : numpy array
Return : mean,median,std_deviation,variance,mode,iqr : float

Note:
1. Assign the values to designated variables
2. Round off to 2 decimal places
'''
mean=round(np.mean(arr),2)
median=round(np.median(arr),2)

std_deviation=round(np.std(arr),2)

variance=round(statistics.pvariance(arr),2)

mode=round(statistics.mode(arr),2)
iqr=round(stats.iqr(arr),2)

return mean,median,std_deviation,variance,mode,iqr

if __name__=='__main__':
array1=[]
n=int(input())
for i in range(n):
array1.append(float(input()))
narray1=np.array(array1)
print(measures(narray1))
Problem2

from itertools import combinations


from itertools import permutations
import numpy as np
import math

def comb_perm(arr):
#Write your code here
'''
Input: arr : numpy array
Return : no_of_comb,no_of_perm : Integer

'''
no_of_comb= len(list(combinations(arr,2)))
no_of_perm= len(list(permutations(arr,2)))
return no_of_comb,no_of_perm

if __name__=='__main__':
array1=[]
n=int(input())
for i in range(n):
array1.append(input())
narray1=np.array(array1)
print(comb_perm(narray1))
Example
from scipy import stats
import numpy as np
import statistics
data ={"A": 90,"B": 86,"C":70,"D":95,"E":95,"F":95,"G":95}
values = list(data.values())
print("Mean")
print(np.mean(values))
print("Median")
print(np.median(values))
print("Mode")
print(statistics.mode(values))
print("Standard Deviation")
print(np.std(values))
print("Variance")
print(np.var(values))
print("range")
print(stats.iqr(values))```

Problem3

import math

def dancers():
'''
output: ans : Integer
'''
#Write your code here
#Assign your value to variable ans

boy=math.factorial(6)/((math.factorial(3))*math.factorial(3))
girl=math.factorial(5)/((math.factorial(2))*math.factorial(3))

ans=boy*girl
return int(ans)

if __name__=='__main__':
print(dancers())
Problem4

from scipy import stats

def binomial():
'''
output: ans : Float
'''
#Write your code here
#Assign the probability value to the variable ans
#Round off to 2 decimal places

p=0.6
n=4
r=0
a = stats.binom.pmf(r, n, p)

ans =round(1-a,2)
return ans

if __name__=='__main__':
print(binomial())

Problem5

from scipy import stats

def poisson():
'''
output: ans : Float
'''
#Write your code here
#Assign the probability value to the variable ans
#Round off to 2 decimal places

ans=round(stats.poisson.pmf(15,10),2)

return ans
if __name__=='__main__':
print(poisson())

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