# Six Sigma Formula

Does anyone have the SQL code to perform a Six Sigma Calculation?

Six Sigma like the Motorola Black Belt type? I didn’t know that there is a formula/calculation - I thought it was more of a QA process/methodology.

Its simply a way to convert defects per opportunity to a value between 0 thru 6.
1 sigma is 3.4 defects per 1,000,000 opportunities

What we need is mathematical genius. I need an algorithm that will return the folowing:

x | y(x)

694,000 | 1
308,000 | 2
67,000 | 3
6,200 | 4
230 | 5
3.4 | 6

OK, I’ve got it!

```switch({Root Container.value}, 694000,308000,67000,6200,230,3.4 1,2,3,4,5,6, -1)```

Maybe nested if statements?

```if({Root Container.value}>694000, 1, if({Root Container.value}>308000, 2, if({Root Container.value}>67000, 3, if({Root Container.value}>6200, 4, if({Root Container.value}>230, 5, 6, ) ) ) ) )```

I looked it up online, and I have no idea if there if this is acurate, but it looks like it might be =). To calculate 6-sigma, you have to break it down into a few parts:

6-sigma = sigma * 6 + the calculated mean.
sigma = sqrt(1/N*SUM(x-AVG(x))^2)

You can do this in a few steps

1. Calculate the average of your values
3. Divide by the number of values
4. Take the square root of that

so a python script would look something like:

[code]values = my set of values
#calculate average
mean = 0
count = 0
for value in values:
mean = mean + value
count = count + 1
mean = mean/count

#calculate sum
sum = 0
for value in values:
sum = sum + (value-mean)*(value-mean)

#calculate sigma
sigma = sqrt(sum/count)

#calculate 6-sigma
sixsigma = sigma/6 + mean
[/code]