Question

(or Gaussian) probability P(x) where, dr is the variance and μ is the mean. 1. Define the array x as the numbers x--5,-4.....5 2. Use numpy to evaluate px) using x and Name these arrays p-a, p.b, and p-c, respective ly.

How is this done using python programming?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#Loading Libraries
import numpy as np
import math

#Define Probability Density Function
def p_x(x, mu, sigma_square):
A = math.sqrt(2 * math.pi * sigma_square)
B = float(((x - mu) ** 2)) / sigma_square
C = -(float(B)/2)
value = math.exp(C) / A
return value

#Question 1:
x = np.array([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5])

#Question 2:
# (a)
p_a = np.zeros(len(x))
for i in range(len(x)):
p_a[i] = p_x(x[i], mu = 0, sigma_square=1)

print(p_a)

# (b)
p_b = np.zeros(len(x))
for i in range(len(x)):
p_b[i] = p_x(x[i], mu = 1, sigma_square=1)

print(p_b)

# (c)
p_c = np.zeros(len(x))
for i in range(len(x)):
p_c[i] = p_x(x[i], mu = 0, sigma_square=2)

print(p_c)

** For any confusion or answer mismatch please comment.

Add a comment
Know the answer?
Add Answer to:
How is this done using python programming? (or Gaussian) probability P(x) where, dr is the variance...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Answer 5 and 6, using R programming code: 5. We have seen the following functions dnorm...

    Answer 5 and 6, using R programming code: 5. We have seen the following functions dnorm pnorm qnorm normal probability density function normal cumulative distribution function normal quantile function a. Let X have a normal distribution with mean 100 and variance 100. Find the 90th percentile of X by calling the function qnorm in two ways: (i) specify the arguments by position, and (ii) specify the arguments by complete names. b. Find P(X > 90) using the function pnorm in...

  • Calculation need to be done using R Suppose X is a random variable taking on possible...

    Calculation need to be done using R Suppose X is a random variable taking on possible values 1,2,3 with respective probabilities.4, .5, and .1. Y is a random variable independent from X taking on possible values 2,3,4 with resp probabilities.3, .3, and .4. Use R to determine the following. a) Find the probability P(X*Y = 4) b) Find the expected value of X. c) Find the standard deviation of x. d) Find the expected value of Y. e) Find the...

  • 3. Use the probability generating function Px)(s) to find (a) E[X(10)] (b) VarX(10)] (c) P(X(5)-2) . ( 4.2 Probability Generating Functions The probability generating function (PGF) is a us...

    3. Use the probability generating function Px)(s) to find (a) E[X(10)] (b) VarX(10)] (c) P(X(5)-2) . ( 4.2 Probability Generating Functions The probability generating function (PGF) is a useful tool for dealing with discrete random variables taking values 0,1, 2, Its particular strength is that it gives us an easy way of characterizing the distribution of X +Y when X and Y are independent In general it is difficult to find the distribution of a sum using the traditional probability...

  • Python, given a code in class i just need help with the third bullet point ; using a and n (defin...

    Python, given a code in class i just need help with the third bullet point ; using a and n (defined in the second picture of python code) find the first digit for k! for k =1,...,n. you dont have to type in all this code just help me write the code in the first picture where it says: def benford(a): b = [0 for d in range(1,10)] #Do everthything in here return b 2.2 Generating data In this assignment...

  • python / visual studio Problem 1: Random Walk A random walk is a stochastic process. A...

    python / visual studio Problem 1: Random Walk A random walk is a stochastic process. A stochastic process is a series of values that are not determined functionally, but probabilistically. The random walk is supposed to describe an inebriated person who, starting from the bar, intends to walk home, but because of intoxication instead randomly takes single steps either forward or backward, left or right. The person has no memory of any steps taken, so theoretically, the person shouldn't move...

  • Your mission in this programming assignment is to create a Python program that will take an...

    Your mission in this programming assignment is to create a Python program that will take an input file, determine if the contents of the file contain email addresses and/or phone numbers, create an output file with any found email addresses and phone numbers, and then create an archive with the output file as its contents.   Tasks Your program is to accomplish the following: ‐ Welcome the user to the program ‐ Prompt for and get an input filename, a .txt...

  • Assignment 6: Recursion Learning Outcomes • Learn how to craft solutions using recursion instead of loops....

    Assignment 6: Recursion Learning Outcomes • Learn how to craft solutions using recursion instead of loops. Instructions This assignment will be different than previous assignments (and most assignments which come after it). In this assignment, you will be crafting four solutions to four different problems. This assignment will also have special requirements regarding how you may code. You are not allowed to use assignment statements. This includes using preincement, postincrement, predecrement, and postdecrement. You are allowed to use assignment to...

  • Economics- Probability and stats 1. Find the value of the 75th percentile of the following array:...

    Economics- Probability and stats 1. Find the value of the 75th percentile of the following array: 5,10,43,9,8,6,2,5 A) 8 B) 9 C) 9.5 D) 8.5 2. Two independent events, A and B, where the P(B) is 0.44 and the probability that A does not occur or B occurs is 0.74. What is the probability that event A occurs? A) 0.3 B) 0.54 C) 0.46 D) 0.28 3. Which of the following is FALSE? A) B) A sampling distribution is a...

  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT