New Table( "Monte Carlo Sample Size Example",
Add Rows( 35000 ),
New Script(
"Distribution to Simulate",
Distribution(
Nominal Distribution( Column( :Defect Actual Category ) ),
Nominal Distribution( Column( :Correct Category Identified ) )
)
),
New Column( "Defect Actual Category",
Numeric,
"Ordinal",
Format( "Best", 12 ),
Formula( Max( Floor( Random Uniform( 0, 10 ) ), 1 ) )
),
New Column( "Sample Size",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( 20 )
),
New Column( "Sampled Rows Sorted",
Numeric,
"Nominal",
Format( "Best", 12 ),
Formula( If( Row() <= :Sample Size[1], 1, 0 ) )
),
New Column( "Sampled Rows Shuffled",
Numeric,
"Nominal",
Format( "Best", 12 ),
Formula( :Sampled Rows Sorted[Col Shuffle()] )
),
New Column( "Sampled Defect Category",
Numeric,
"Ordinal",
Format( "Best", 12 ),
Formula( If( :Sampled Rows Shuffled == 1, :Defect Actual Category ) ),
Set Display Width( 135 )
),
New Column( "Actual Defect Category",
Numeric,
"Nominal",
Format( "Best", 12 ),
Formula( If( Row() == 1, Mode( :Defect Actual Category << Get VAlues ) ) ),
Set Display Width( 130 )
),
New Column( "Predicted Default Category",
Numeric,
"Nominal",
Format( "Best", 12 ),
Formula( If( Row() == 1, Mode( :Sampled Defect Category << Get Values ) ) )
),
New Column( "Correct Category Identified",
Numeric,
"Nominal",
Format( "Best", 12 ),
Formula(
If( Row() == 1,
:Actual Defect Category == :Predicted Default Category
)
),
Value Labels( {0 = "No", 1 = "Yes"} ),
Use Value Labels( 1 )
)
);