0

Please could you help me by fixing the error with my code. When I print last line I get a syntax error message:

import math


m_ = 900         # identifier for normal distribution mean   [mm]
s_d = 1          # identifier for normal distribution standard deviation [mm]

print "DISTRIBUTION OF A PLATE WIDTH:" " MEAN", "=",m_,"," "STD DEV", "=", s_d
print ""
print "Using functions from the math library ..."


# The probability density function(pdf) for a normal distribution with mean m_ and 
standard deviation s_d    
ftotal = 0
term = 0.0
count = 0
while abs(term) > 911:
    ftotal += term
    count += 1
    term = term * xx / float(count)


print "x"  "          " " f(x)" "           " " F(x)"
print "890" ""  (1 / ((s_d * (2 * math.pi) ** -0.5)) * math.exp((- (x - m_) ** 2) / (2 * (s_d) ** 2),   0.5 * (1 + math.erf((x - m_) / s_d * m.sqrt(2))
4
  • 1
    align the code in your while loop. It is not clear what your while loop has? Commented Feb 1, 2013 at 6:04
  • 1
    Also missing operator before 0.5 in (2 * (s_d) ** 2) 0.5 from last line. Commented Feb 1, 2013 at 6:06
  • sorry, these are two separated formulas, but I do not know how to separate them correctly Commented Feb 1, 2013 at 6:09
  • 1
    Define x first. by xx do you mean x*x? In last line, at the end you have written m.sqrt(2) I think you mean math.sqrt(2). Also put , after "890". And put matching braces in the last line. Commented Feb 1, 2013 at 6:20

1 Answer 1

3

Define x before the while loop. From the last two lines where you have denoted x by 890 so I am guessing x = 890.

x = 890
#your while loop goes here

print "x"  "          " " f(x)" "           " " F(x)"
print "890" ,  (1 / ((s_d * (2 * math.pi) ** -0.5))) * math.exp((- (x - m_) ** 2) / (2 * (s_d) ** 2))  , 0.5 * (1 + math.erf((x - m_) / s_d * math.sqrt(2)))

I can't remember the exact formula but if the above expressions are correctly put, you won't get a syntax error.

Sign up to request clarification or add additional context in comments.

1 Comment

If this answers your question, you can accept the answer by clicking on the tickmark just to the left of answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.