Question

In: Computer Science

Program in python an example code for the random variable (Bernoulli distribution), where the user informs...

Program in python an example code for the random variable (Bernoulli distribution), where the user informs the data and parameters necessary to generate the cumulative distribution function (CDF.)

Solutions

Expert Solution

from scipy.stats import bernoulli as br 
import matplotlib.pyplot as plt
print("give the value's of  probability of getting success(0-1): ")
prob = float(input())

#find the statistical values
mean, variance, skewness, kurtosis = br.stats(prob, moments = 'mvsk')

#it will print the mean
print("mean = ", mean)

#it will print the variance 
print("Variance = ", variance)

#it will print the  Skewnes
print("Skewness = ", skewness)

# it will print the kurtosis
print("kurtosis = ", kurtosis)
 

output screen:

mean = br.mean(prob)

#get standard deviation
std = br.std(prob)

#plotting the cdf

z = [0, 1]
print("CDF = ", br.cdf(z, prob))

plt.scatter(z, br.cdf(z, prob), label = "CDF",marker='*',color='r')
plt.title("CDF")
plt.xlabel("Data point")
plt.ylabel("probability")
plt.legend()
plt.show()

output screen :

if you have any doubts regarding this question than feel free to ask .


Related Solutions

Program a code for the random variable (Exponential distribution), where the user informs the data and...
Program a code for the random variable (Exponential distribution), where the user informs the data and parameters necessary to generate the Probability Density function (PDF) and the Cumulative Distribution Function (CDF).
Write a python code using a continuous random variable and using uniform distribution to output the...
Write a python code using a continuous random variable and using uniform distribution to output the expected weight of students in a class.
(CODE IN PYTHON) Program Input: Your program will display a welcome message to the user and...
(CODE IN PYTHON) Program Input: Your program will display a welcome message to the user and a menu of options for the user to choose from. Welcome to the Email Analyzer program. Please choose from the following options: Upload text data Find by Receiver Download statistics Exit the program Program Options Option 1: Upload Text Data If the user chooses this option, the program will Prompt the user for the file that contains the data. Read in the records in...
9) This is in Python Code a program that allows the user to manage its expenses...
9) This is in Python Code a program that allows the user to manage its expenses accepting the following commands: - Add <player_name> -> This command adds a new player to the system. Assume there can’t be repeated names. If a name already exists then an error is shown to the user. - Score <player_name> <score> -> This command adds the score to the player with the name player-name. Each score needs to be added individually - Report -> This...
CODE IN PYTHON 1. Write a program that asks the user for the number of slices...
CODE IN PYTHON 1. Write a program that asks the user for the number of slices of pizza they want to order and displays the total number of dollar bills they owe given pizza costs 3 dollars a slice.  Note: You may print the value an integer value. 2. Assume that y, a and b have already been defined, display the value of x: x =   ya+b    3. The variable start_tees refers to the number of UD T-shirts at the start...
Write a program function code in Python that prompts the user to enter the total of...
Write a program function code in Python that prompts the user to enter the total of his/her purchase and add 5% as the VAT. The program should display the total without and with VAT. ( that mean i should ask the user to enter the number of their item " so i think that i should use range" then print the result with and without the VAT )
CODE IN PYTHON: Your task is to write a simple program that would allow a user...
CODE IN PYTHON: Your task is to write a simple program that would allow a user to compute the cost of a road trip with a car. User will enter the total distance to be traveled in miles along with the miles per gallon (MPG) information of the car he drives and the per gallon cost of gas. Using these 3 pieces of information you can compute the gas cost of the trip. User will also enter the number of...
*** Using Python *** Your program must prompt the user for their city or zip code...
*** Using Python *** Your program must prompt the user for their city or zip code and request weather forecast data from openweathermap.org. Your program must display the weather information in an READABLE format to the user. Requirements: Create a Python Application which asks the user for their zip code or city. Use the zip code or city name in order to obtain weather forecast data from: http://openweathermap.org/ Display the weather forecast in a readable format to the user. Use...
Post a Python program that contains an array variable whose values are input by the user....
Post a Python program that contains an array variable whose values are input by the user. It should the perform some modification to each element of array using a loop and then the modified array should be displayed. Include comments in your program that describe what the program does. Also post a screen shot of executing your program on at least one test case.
---- Python CIMP 8A Code Lab 4 Write a program that asks the user to enter...
---- Python CIMP 8A Code Lab 4 Write a program that asks the user to enter 5 test scores. The program will display a letter grade for each test score and an average grade for the test scores entered. The program will write the student name and average test score to a text file (“studentgrades.txt”). Three functions are needed for this program. def letter_grade( test_score) Test Score Letter Grade 90-100 A 80-89 B 70-79 C 60-69 D Below 60 F...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT