2013-02-01 5 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를 정의하십시오. 마지막 두 줄부터 x를 890으로 표시 했으므로 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