Sunday, July 26, 2009

Chebyshev's Inequality to Roughly Estimate Area Under an Unknown Probability Density Curve: Reposted from www.SixSigmaPractice.multiply.com

I have always been fascinated by this generalized area under the curve theorem.
Though the estimate in itself is very weak, Chebyshev's inequality provides a very strong statistical basis for control charting.
Here is a utility that compares the actual area under the curve against to that estimated by Chebyshev's inequality.


The JMP JSL Script




Clear Globals();
new=EXPR(dt=open());
use_curr=expr(dt=Current Data Table());
if(is empty(Current Data Table()),new,use_curr);
bound=1.5;
j = 1;
col_list = {};
For( j = 1, j <= N Col( dt ), j++,
col_list[j] = Column( j ) << get name
);


COMM_RUN = Expr(
col = Column( col_name );
modelling=col<<get modeling type;
CONT=EXPR(
val1 = col << get as matrix;
counter = N Rows( val1 );
T_counter = 0;
mu = Mean( val1 );
sigma = Std Dev( val1 );
i = 1;
For( i = 1, i <= counter, i++,
If( val1[i, 1] <= mu + bound * sigma & val1[i, 1] >= mu - bound * sigma,
T_counter = T_counter + 1;
i = i + 1;
,
i = i + 1
)
);

Actual = T_counter / counter * 100;
T_estimate = (1 - (1 / (bound ^ 2))) * 100;
);
NON_CONT=EXPR(Throw ("Data Column does not contain a continous variable data"));
if(modelling=="Continuous",CONT,NON_CONT);
);

COMM_PRINT = Expr(
PRINT_TEXT = "Actual area inside mean +/- " ||char(bound) || "*sigma is " || Char( round(Actual,2) ) || " while Chebyshev's inequality estimate is " || Char( round(T_estimate,2) );
PRINT_VALUES = "Mean is equal to " ||char(round(mu,3)) || ". Sigma is equal to " ||char(round(sigma,3)) || ". The bounded interval is equal to " ||char(round(mu-bound*sigma,3)) || " to " ||char(round(mu+bound*sigma,3)) || ".";
Print( PRINT_VALUES );
Print( PRINT_TEXT );
);


COMM_OUTPUT = Expr(
OUTPUT_REPORT = New Window( "Results",
Border Box(
Left( 10 ),
Panel Box( "Simulation Result for " || char(col),
Text Box(" "),
V LIST BOX(
Text Box( "" ),
Text Box( PRINT_VALUES ),
Text Box( " " ),
Text Box( PRINT_TEXT ),
Text Box(" "),
Text Box( "sixsigmapractice.multiply.com" )
)
)
)
)
);

New Window( "Interface",
Border Box(
Left( 10 ),
Panel Box( "Set values and click on RUN",
V List Box(
V List Box(
H List Box(
Text Box( "Set Bound = k" ),
Text Box( " " ),
combo_list = Combo Box(
{"1.5", "2", "2.5", "3", "3.5", "4", "4.5", "5", "5.5", "6"},
COMBO_COMM = Expr(
k = combo_list << getselected;
bound = Num( k );
);
COMBO_COMM;
),

),
Text Box( " " ),
H List Box(
Text Box( "Select Column" ),
Text Box( " " ),
col_select = Combo Box( col_list ),
COL_COMM = Expr( col_name = col_select << get );
COL_COMM;
)
),
Text Box( " " ),
Panel Box( "Command Button",
Button Box( "RUN ESTIMATE",
COMBO_COMM;
COL_COMM;
COMM_RUN;
COMM_PRINT;
COMM_OUTPUT;
OUTPUT_REPORT << reshow;
OUTPUT_REPORT<<move window(250,50)
)
)
)
)
)
);

No comments:

Post a Comment

 
Custom Search