2013-02-01 174 views
0

请你能帮我解决我的错误代码。当我打印最后一行我得到一个语法错误消息:python语法错误输出

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)) 
+1

对齐while循环中的代码。目前还不清楚你的while循环是什么? – Hussain

+1

在最后一行的'(2 *(s_d)** 2)0.5'中的'0.5'之前还缺少运算符。 – Hussain

+0

对不起,这些是两个分开的公式,但我不知道如何正确分开它们 –

回答

3

while循环之前定义X。从你用890表示x的最后两行,所以我猜测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))) 

我不记得确切的公式,但如果上述表达式正确放置,您将不会得到语法错误。

+1

如果这回答你的问题,你可以通过点击答案左侧的标记来接受答案。 – Hussain