This page is under development. Comments are welcome, but please load any comments in the comments section at the bottom of the page. Please include your wiki MONIKER in your comment with the same courtesy that I will give you. Its very hard to reply understandably without some background of the correspondent. Thanks,[gold] ---- <> ---- **Introduction** [gold] Here is some eTCL starter code for calculations estimating spare parts or spare drives for a cloud backup system. This report references both the poisson and normal distributions, as implemented in TCL. *** Initial solution *** As a trial design, the cloud backup system is an assembly of 45 drives in a case with N1 assemblies in the installation. The drives are used 24/7 for a time interval of 90 days.The product N1*45 devices is much much greater than 10 devices. The eTCL calculator estimates the required number of spare parts or spare drives for a 95% confidence in the normal distribution. In each of 3 testcases, a different mean time between failure (MTBF ) in hours was assigned to the drives. Rounding up to the nearest whole number, an assembly of 100000 hours MTBF needed 3 spare drives, 200000 hours MTBF needed 2 spare drives, and 300000 hours MTBF needed 2 spare drives over the time interval and specified 95 percent confidence. *** Testcases for spare parts function *** The three drive types of 100000, 200000, and 300000 hour MTBF were converted into annualized failure rates (AFR) for 3 testcases. Converting the 100000 hour MTBF to years, the first drive type was 100000 hours/ 8760 hours in year or 11.415 years. This was 1 failure over 11.415 years which gave an annualized failure rate (AFR) of 1/11.415, 0.0876, 8.76 percent. For a testcase of 45 drives, the predicted (average) failure was 45*8.76*1E-2, or 3.9 drives per year. Converting the 200000 hour MTBF to years, the second drive type was 200000 hours/8760 hours in year or 22.831 years. This was 1 failure over 11.415 years gave an annualized failure rate (AFR) of 1/22.831, 0.0438, 4.38 percent. For a case of 45 drives, the predicted (average) failure was 45*4.38*1E-2, or 1.971 drives per year. Converting the 300000 hour MTBF to years, the third drive type was 300000 hours/8760 hours in year or 34.246 years. This was 1 failure over 34.246 years which gave an annualized failure rate (AFR) of 1/34.246 , 0.0292, 2.92 percent. For a case of 45 drives, the predicted (average) failure was 45*2.92*1E-2, or 1.314 drives per year. For comparison in the cloud backup industry, the annualized failure rate for 24/7 disk drives ranged normally between 1 and 4 percent per year. However, AFR outliers have been reported as high as 14 percent per year ( for refurbished or rehoused consumer desktop drives used 24/7 commercially ). *** Spare parts function from a poisson distribution *** For the spare parts function on a poisson distribution, the mean or mu is N* (1/MTBF)*((interval period in days)/(365 days in year)). The standard deviation or sigma in the poisson distribution is the square root of the mean. So for the spare parts function, the sigma is sqrt < N* (1/MTBF)*((interval period in days)/(365 days in year)) > . The interval adjustment is written in the software, but will be left aside for the remaining derivation as a complicating factor. The spare parts function could be written as mu+kay*sigma on a yearly basis. Kay is a constant adjusted from 1*sigma, 2*sigma, or up to 3*sigma to match the desired confidence levels. The trial design criterion would spare devices greater than > mu+2 * sigma per year. The mu+2*sigma would be the 97 percent confidence level. Since N* (1/MTBF) equals the annual failure rate (AFR), the spare parts formula is equivalent to AFR plus 2 * sqrt(AFR). For an example in rounded numbers, the 100000 hour MTBF in a case of 45 drives converted to mean or mu of 4 failures per year. For 97c confidence, the spare parts formula would be > mu+2*sigma, mu+2*sqrt(mu), 4+2*sqrt(4), 8 spare drives per year. On a quarterly basis, the suggested spare parts would be 8/4 or 2 spare drives per quarter. The greater than > in the trial formula is used to indicate rounding up to next higher integer, especially not truncation for estimates based on yearly definitions. ***Spare Transformers in complex problem*** A combined solar plant and transformer yards plans a yearly estimate of spares for 150 transformers. The Nahman paper was used to develop this problem with many context changes. Specs on the individual units, calculations on units without spares, and even a crib sheet on the possible poisson solution will be examined as a problem, then the various eTCL softwares will be deployed . The customary planning period is 1 year or 8760 hours. There were 150 transformers consisting of 38 new models and 112 old models; installation has 25% new models and 75% old models. For all transformers, the rated lifetime under maintenance was 45 years or 394200 hours. The records of the solar power plant show 34 failures over the last 15 years for 150 units, average failure rate is 34/(150*15) or 0.015 failures per year. The current or spec failure rate is 0.012 failures per year for the new model (initial 2 years) and 0.015 failures per year for the older model. The units are scheduled for maintenance and refurbishment every three years. Maintenance consists of changing oil, inspection of cracks, replacement of minor parts, rust treatment, etc. Both new and old models experience deterioration as the three year limit is approached and failure rate for the third year is mean 0.015 failures per year for both models. For one unit without spares, the experimental_breakpoint from exponential model was 30 years and the 0.0342 experimental_failure_rate_per_year from exponential model. For one unit after maintenance without spares, the service warranty was 3 years, the service MTTF is 1.946 year, and the service MTTR is 1.054 year. The MTTF_D was rated 3.892 years to dangerous failure and the availability without spares was MTTF/MTTB, 1.946/3, 0.666 years. The crib sheet has classic poisson spares at 6.3 spares for 95%C. The economic selection of purchasing spares has factors that the old model transformer has finished factory production, the new models cost $50,000 dollars each ( $50k), and significant downtime means loss of revenue. In using the eTCL calculator, rules of thumb are recommended to check the calculator results and establish brackets or limits for the calculator results. For a rule of thumb on simple replacement, the expected failures for the year is 150*0.012, 1.8 failures. Two more rules of thumb was that the problem has sufficient points ( N>10) to fall under the central limit theorem for narrow percentiles and has sufficient points (N>50) to establish narrow sigma breakpoints. For another rule of thumb on simple replacement, the expected failures for the year is 150*0.012, 1.8 failures. After rounding up, the simple replacement is spares=1 (spare per failure)* 2 failures, 2 spares for approximate 50%C. From rule of thumb, spares for 95%C = 3 sigma_breakpoints/failure*1.8, 5.4, rounding 6 spares for 95%C. Continuing on to the eTCL calculator for normal distribution, there is {ceil 6.339 } or 7 spares for 95%C and there is {ceil 8.8136} or 9 spares for the 99.8%C. For comparison, the 6 spares from the rule of thumb and poission were fairly close to the 7 spares from the normal distribution , both at 95%C. From this and other problems, the spares assigned from the normal distribution seem about 20% more generous than the classic poisson solution. *** Push Button Operation*** For the push buttons in the eTCL calculator, the recommended procedure is push testcase and fill frame, change first three entries etc, push solve, and then push report. Report allows copy and paste from console. For testcases in a computer session, the eTCL calculator increments a new testcase number internally, eg. TC(1), TC(2) , TC(3) , TC(N). The testcase number is internal to the calculator and will not be printed until the report button is pushed for the current result numbers. The current result numbers will be cleared on the next solve button. Aside from the TCL calculator display, when one presses the report button on the calculator, one will have console show access to the functions (subroutines). There is belief that time intervals below 90 days and above 1000 days (~ 3 years) might violate the assumption of constant failure rate and other assumptions of the calculator. For example, many countries and regions have frequent lightning strikes during spring, monsoon season, or high Colorado mountain summer. Frequent failures due to lightning strikes during a month might absorb a years worth of spares. Another consideration for the batteries or biologicals like tulip bulbs is the mails or roads freezing up over a winter season. Hence inputs below 90 days might not be useful, if the spares can not be replaced until the spring thaw. The linear algorithm that prorates the spares from the time interval should be checked with industry specs/history beyond 3 years operation. The research will have to gather some testcases to see if calculator is useful beyond 3 year interval. Housekeeper solution. Lets look at the Housekeeper solution for a modest set of devices of possible high failure rates, which would test the lower and upper limits of the calculator (N<<50, time>>360 days). Including other results, the lower limits and upper limits on calculator entries were tested several times, especially on Testcase 6 (N<<50, time=500, >>360 days here ). True in Testcase 6, the solution of 364 spare parts was greater than the expected 333 failures in 500 day interval. However, the solution may have cut too low into a budget of safety spares for high failure rate devices, due to approaching the limits of the calculator assumptions, especially from the Central Limit Theorem. Most of the blessed solutions to the spare parts problems give number of spares as 2X,3X,&4X times the number of expected failures. A good analog from the old housekeeper days is that the fuse box of 20 metal fuses for the house would have two boxes of four fuses or 8 spare fuses. The housekeeper expected two fuses to fail during winter electric heating or two fuse failures per season (8 failures per year), so the housekeeper solution was that spares on hand were 4X times the expected number of failures in a season. In fact, the housekeeper kept spares for almost half of the 20 active devices (fuses) in the fuse box. Of course, the metal fuses were cheap in those days and the testcases here looked at mostly high dollar items like transformers and computer servers. The eTCL calculator is working well in the expected range of operation: 1) N >> 10, 2) time interval of 90 to 365 days of year, and 3) constant failure rate over year. The calculator is purposely left flexible on input limits, but there are some cautions. Since confidence levels are used in the eTCL calculator, there must be sufficient N (10,20,50 points) to establish a 95% or other confidence interval of desirably small percentile width (2%,1%,0.5% width). Also, there should be sufficient N (50 points) in the parts distribution to fall under the Central Limit Theorem. The Central Limit Theorem allows treatment of the parts distribution as a normal distribution and allows the treatment and accuracy of the sigma breakpoints used in the spare parts function. The distance accuracy of the sigma breakpoints from the center mean point in the spare parts function is directly proportional to number of parts: N=10,20,50 points = 2*2%,2*1%, 2*0.5% spare parts accuracy. *** Pseudocode and Equations *** ====== MTBF = mean time between failures in hours = 10E9*(1/FIT). 8760 hours = 1 year N = number of maintained parts or devices, points cited in distribution S = number of spare parts or devices in inventory or ordered per time interval sigma = standard deviation of parts distribution, sigma = 1, especially if parts modeled as normal distribution AFR = 1/(MTBF in years) MTTF = mean time to failure MTTR= mean time to repair MTBF = MTTF + MTTR MTTF = (time_interval*number_devices_tested)/ (number devices failed) (number devices failed) = (time_interval*number_devices_tested)/ MTTF if {MTTR << MTTF} {MTBF is roughly equivalent to MTTF} MTTF(D) = 2 · MTTF() , where MTTF(D) is considered dangerous or catastrophic failure,1/2 of failures and MTTF() considered non-dangerous, 1/2 of failures MTTF(D) = 2 · MTBF , under certain conditions {MTTR << MTTF} average failures over time interval= n_quantity*AFR percent*1E-2* (time_interval_days/365 days in year) spare devices > failures over time interval, minimal design criterion spare devices > 2 * average failures over time interval, trial design criterion spare devices > failures per year + 0.13* sqrt (failures per year) , rule of thumb for >55% confidence spare devices > failures per year + 0.5* sqrt (failures per year) , rule of thumb for >68% confidence spare devices > failures per year + 1.* sqrt (failures per year) , rule of thumb for >84% confidence spare devices > failures per year + 1.65* sqrt (failures per year) , rule of thumb for >95% confidence spare devices > failures per year + 2.* sqrt (failures per year) , rule of thumb for >97% confidence spare devices > failures per year + 2.5* sqrt (failures per year) , rule of thumb for >99% confidence spare devices > failures per year + 3.* sqrt (failures per year) , rule of thumb for >99.9% confidence repairable > MTBF non-repairable > MTTF FIT failures in time = failures per billion device_hours FIT reports normally use a 60% confidence level number of expected failures=FIT*Operating hours * number of devices DPPM= Defects per parts per million exponential probability distribution > electronic components lognormal probability distribution > incandescent lightbulbs, lasers,tires Availability = MTTF/MTBF operational availability, Ao=time_on/(time_on+time_off) MTBF = MTTF + MTTR MTBF = 1/( FR1 + FR2 + FR3 + ...........FR_N) MTTDL =Mean Time To Data Loss MTTDL = MTBF/N_DISKS ====== ---- ***Testcases Section*** **** Testcase 1 **** %|table 1|printed in| tcl wiki format|% &| quantity| value| comment, if any|& &| testcase number:|1 | |& &| 100000.0 :|MTBF mean time between failures in hours| |& &| 45.0 :|n quantity devices| |& &| 90.0 :|time interval days| |& &| 1.645 :|95 percentile | |& &| 11.415 :|answers:MTBF in years | |& &| 8.76 :|AFR annualized failure rate percent/year | |& &| 0.972 :|average failures from prorated AFR over time interval| |& &| 2.593 :|required spares from normal distribution over time interval| round up to integer 3 |& ---- **** Testcase 2 **** %|table 2|printed in| tcl wiki format|% &| quantity| value| comment, if any|& &| testcase number:|2 | |& &| 200000.0 :|MTBF mean time between failures in hours| |& &| 45.0 :|n quantity devices| |& &| 90.0 :|time interval days| |& &| 1.645 :|95 percentile | |& &| 22.831 :|answers:MTBF in years | |& &| 4.38 :|AFR annualized failure rate percent/year | |& &| 0.486 :|average failures from prorated AFR over time interval| |& &| 1.632 :|required spares from normal distribution over time interval| round up to integer 2 |& ---- **** Testcase 3 **** %|table 3|printed in| tcl wiki format|% &| quantity| value| comment, if any|& &| testcase number:|3 | |& &| 300000.0 :|MTBF mean time between failures in hours| |& &| 45.0 :|n quantity devices| |& &| 90.0 :|time interval days| |& &| 1.645 :|95 percentile | |& &| 34.246 :|answers:MTBF in years | |& &| 2.92 :|AFR annualized failure rate percent/year | |& &| 0.324 :|average failures from prorated AFR over time interval| |& &| 1.260 :|required spares from normal distribution over time interval| round up to integer 2 |& ---- **** Testcase 4 **** %|table 4|printed in| tcl wiki format|% &| quantity| value| comment, if any|& &| testcase number:|4 | |& &| 700000.0 :|MTBF mean time between failures in hours| |& &| 45.0 :|n quantity devices| |& &| 1095.0 :|time interval days| |& &| 1.645 :|95 percentile | |& &| 79.908 :|answers:MTBF in years | |& &| 1.251 :|AFR annualized failure rate percent/year | |& &| 1.689 :|average failures from prorated AFR over time interval| |& &| 3.827 :|required spares from normal distribution over time interval| round up to integer 4 |& ---- **** Testcase 5 **** %|table 5|printed in| tcl wiki format|% &| quantity| value| comment, if any|& &| testcase number:|5 |test of calculator lower limits |& &| 400.0 :|MTBF mean time between failures in hours| warranty of parts, supplied with problem |& &| 2.0 :|n quantity devices|warning!, testing lower_limit_N>10|& &| 0.003534:|lambda= failure rate per hour|supplied with problem |& &| 1.4 :|expected failures on one part during warranty period|supplied with problem |& &| 16.0 :|time interval days|warning!, testing lower_limit_days>90 |& &| 1.645 :|95%C percentile | ref. normal distribution |& &| 0.04566 :|answers:MTBF in years | |& &| 2190.0 :|AFR annualized failure rate percent/year |small lifetime gives many failures in year|& &| 1.920 :|average failures from prorated AFR over time interval| |& &| 4 :|home brew solution spares from poisson, 95%C percentile |supplied with problem |& &| 4.199 :|required spares from normal distribution over time interval|round up to 5 |& &| 4 or 5 :|95%C spares from both poisson and normal d. |seem reasonably close|& &| 4 ot 5 > 1.4 :|95%C spares > expected5 failures in 16 day interval |95%c spares about 3*failures |& ---- %|textbook table solution gives 4 spares | warranty=400 hours | 1.4 failures in 400 hours| 0.003534 f/hr | 16 days interval | MTTF=283 hours |% %|from real_life problem | |||poi. & nor. distributions from CRC rubber & textbook tables||% &| probability of X row >>> | p(0)| p(1)| p(2) | p(3) | p(4) |& &| textbook poisson cdf,L=1 | .3679 | .7358 | .9197 | .9810 |.9963 |& &| textbook poisson pdf,L=1 | .3679 | .3679 | .1839 | .0613 |.0153 |& &| textbook normal cdf,S=1 | .5000 | .8413 | .9773 | .9987 |1.0 |& &| textbook normal pdf,S=1 | .3989 | .2420 | .0540 | .0044 |.0001 |& &| solution of 4 spares > 95% | | | | 4 spares col. ^^^^ | |& &| % difference in cum. curves| | 14.3% | 6.2% | 1.8% | 0.37% |& ---- **** Testcase 6 **** %|table 6|printed in| tcl wiki format|% &| quantity| value| comment, if any|& &| testcase number:|6 |test of both lower limits and upper limits on calculator |& &| 900.0 :|MTBF mean time between failures in hours| warranty of parts, supplied with problem |& &| 25.0 :|n quantity devices | warning!, testing lower_limit_N>50|& &| 500.0 :|time interval days| warning!, testing upper_limit days>365 |& &| 13.3:|expected failures in time interval|12000 hr /900 hr, supplied with problem |& &| 350:|home brew solution for replacements, 13.3>>14*15,not 95%C| supplied with problem, add 10% as safety |& &| 1.645 :|95 percentile=1.645, usual range 1,2,3*sigma | ref. normal distribution |& &| 0.102 :|answers: MTBF in years | |& &| 973.333 :|AFR annualized failure rate percent/year | |& &| 333.333 :|average failures from prorated AFR over time interval| small lifetime gives many failures in year|& &| 364:|home brew solution for poisson d. with 95%C| supplied with problem|& &| 363.366 :|unrounded spare formula from normal distribution | round up to higher integer|& &| 364.0 :|required spares from normal distribution over time interval| rounded up |& &| 364.0 or 364 :|95%C spares from both normal distribution and poisson homebrew| seem close |& &| 364.0 or 364 > 333.333 :|95%C spares > expected 333 failures in 500 day interval| |& ---- ***References:*** * Find The Right Fit With Probability Distributions By David Harper * Hard drive reliability to the test by Peter Bright,Technology Editor at [http://arstechnica.com] * Math Encounters Blog, Spare Parts Math, 27feb2012, Mark Biegert * Assurance. Related Technologies. Volume 9, Number 1. Application of the Poisson Distribution * [https://src.alionscience.com/pdf/POIS_APP.pdf] * MIST: MATLAB Introductory Statistical Toolbox * Poisson distribution calculator, Assurance. Related Technologies * Disk problems contribute to 20% to 55% of storage subsystem failures, Mary Brandel, Computerworld * IEEE TRANSACTIONS ON POWER DELIVERY, VOL. 24, NO. 2, APRIL 2009 Probability Models for Optimal Sparing of Distribution Network Transformers Jovan M. Nahman and Miladin R. Tanaskovic ---- **Appendix Code** ***appendix TCL programs and scripts *** ====== # pretty print from autoindent and ased editor # Spare Parts from Normal Distribution, Calculator V2 # written on Windows XP on TCL # working under TCL version 8.6 # gold on TCL Club, 12Dec2018 package require Tk namespace path {::tcl::mathop ::tcl::mathfunc} frame .frame -relief flat -bg aquamarine4 pack .frame -side top -fill y -anchor center set names {{} {MTBF mean time between failures in hours:} } lappend names {n quantity devices:} lappend names {time interval days : } lappend names {95 percentile=1.645, usual range = 1,2,3*sigma :} lappend names {answers: MTBF in years:} lappend names {AFR annualized failure rate percent/year : } lappend names {average failures from prorated AFR over time interval : } lappend names {required spares from normal distribution over time interval :} foreach i {1 2 3 4 5 6 7 8} { label .frame.label$i -text [lindex $names $i] -anchor e entry .frame.entry$i -width 35 -textvariable side$i grid .frame.label$i .frame.entry$i -sticky ew -pady 2 -padx 1 } proc about {} { set msg "Calculator for Spare Parts from Normal Distribution V2 from TCL, # gold on TCL Club, 12Dec2018 " tk_messageBox -title "About" -message $msg } proc self_help {} { set msg " Spare Parts from Normal Distribution V2 from TCL , # self help listing # problem, Spare Parts from Normal Distribution V2 # 4 givens follow. 1) MTBF mean time between failures in hours: 2) n quantity devices: 3) time interval days: 4) 95 percentile=1.645, usual range = 1,2,3*sigma : # Spare parts from formulas always # should be rounded up. For work, 1.7 horses # behind the plow are effectively 2 horses. # Recommended procedure is push testcase # and fill frame, # change first three entries etc, push solve, # and then push report. # Report allows copy and paste # from console to conventional texteditor. # For testcases, testcase number is internal # to the calculator and will not be printed # until the report button is pushed # for the current result numbers. # >>> copyright notice <<< # This posting, screenshots, and TCL source code is # copyrighted under the TCL/TK license terms. # Editorial rights and disclaimers # retained under the TCL/TK license terms # and will be defended as necessary in court. Conventional text editor formulas or formulas grabbed from internet screens can be pasted into green console. # gold on TCL Club, 12Dec2018 " tk_messageBox -title "Self_Help" -message $msg } proc fuzzy_round_up {args } { set lister {} foreach item $args { if { $item > [int $item ] && $item > 0. } { lappend lister [+ [int $item ] 1.]} if { $item == [int $item ] } { lappend lister [* $item 1.] } if { $item < [int $item ] && $item < 0. } { lappend lister [+ [int $item ] -1.]} } return $lister } proc break_flag_routine { } { global side1 side2 side3 side4 side5 global side6 side7 side8 global spares global testcase_number foreach item { 1 2 3 4 5 6 7 8 9 10 } { set error$item 0 } if { $side1 < .0 } { set side1 .000001 ; set error1 1 ; set error2 1 } if { $side2 < .0 } { set side2 .000001 ; set error1 1 ; set error2 1 } if { $side3 < .0 } { set side3 .000001 ; set error1 1 ; set error2 1 } if { $side4 < .0 } { set side4 .000001 ; set error1 1 ; set error2 1 } if { $side1 < .000001 } { set side2 .000001 ; set error3 1 } if { $side2 < .9 } { set side2 1. ; set error4 1 } if { $side3 < 90. } { set error5 1 } if { $side2 < 40. } { set error6 1 } if { $side4 > 20. } { set side4 20. ; set error7 1 } if { $side4 < .1 } { set side4 .1 ; set error8 1 } if { $side2 < 20. } { set error9 1 } if { $side3 > 1000. } { set error10 1 } if { $error1 == 1 } { puts " warning flag! negative numbers detected in entries" } if { $error2 == 1 } { puts " warning flag! setting program default entries to positive" } if { $error3 == 1 } { puts " lower limit side1! mtbf< limit, setting program default entry" } if { $error4 == 1 } { puts " lower limit side2! N< 1., setting program default entry" } if { $error5 == 1 } { puts " lower limit side3! days<90 limit,no defaults but outside documented range " } if { $error6 == 1 } { puts " lower limit side2! N<40, no defaults but degrading accuracy" } if { $error7 == 1 } { puts " upper limit side4! sigma breakpoint>20, setting defaults for probable error" } if { $error8 == 1 } { puts " lower limit side4! sigma breakpoint<.1, setting defaults for probable error" } if { $error9 == 1 } { puts " lower limit side2! N<20, no defaults set but outside Central Limit Theorem " } if { $error10 == 1 } { puts " upper limit side3! N>1000, no defaults set but documented. range" } foreach item { 1 2 3 4 5 6 7 8 9 10 } { set error$item 0 } return 1 } proc calculate { } { global side1 side2 side3 side4 side5 global side6 side7 side8 global spares global testcase_number incr testcase_number set side1 [* $side1 1. ] set side2 [* $side2 1. ] set side3 [* $side3 1. ] set side4 [* $side4 1. ] set side5 [* $side5 1. ] set side6 [* $side6 1. ] set side7 [* $side7 1. ] set side8 [* $side8 1. ] break_flag_routine set mtbf $side1 set n_quantity $side2 set time_days [* $side3 1. ] set time_hours [* $side3 24. ] #set cl $side4 set term2 [* [/ 1. $mtbf ] $time_hours $n_quantity ] set term3 [sqrt $term2 ] set sigma1 $side4 set spares [+ $term2 [* $sigma1 $term3 ] ] set mtbfyears [/ $mtbf 8760. ] set annual_failure [* [/ 1. $mtbfyears ] 100. ] set annual_failure_rel_days_case [* $n_quantity $annual_failure 1.E-2 [/ $time_days 365. ] ] set side5 $mtbfyears set side6 $annual_failure set side7 $annual_failure_rel_days_case set side8 [ fuzzy_round_up $spares ] } proc fillup {aa bb cc dd ee ff gg hh} { .frame.entry1 insert 0 "$aa" .frame.entry2 insert 0 "$bb" .frame.entry3 insert 0 "$cc" .frame.entry4 insert 0 "$dd" .frame.entry5 insert 0 "$ee" .frame.entry6 insert 0 "$ff" .frame.entry7 insert 0 "$gg" .frame.entry8 insert 0 "$hh" } proc clearx {} { foreach i {1 2 3 4 5 6 7 8 } { .frame.entry$i delete 0 end } } proc reportx {} { global side1 side2 side3 side4 side5 global side6 side7 side8 global spares global testcase_number console show; console eval {.console config -bg palegreen} console eval {.console config -font {fixed 20 bold}} console eval {wm geometry . 40x20} console eval {wm title . " Spare Parts Distribution Report , screen grab and paste from console 2 to texteditor"} console eval {. configure -background orange -highlightcolor brown -relief raised -border 30} puts "%|table $testcase_number|printed in| tcl format|% " puts "&| quantity| value| comment, if any|& " puts "&| testcase number:|$testcase_number | |&" puts "&| $side1 :|MTBF mean time between failures in hours| |&" puts "&| $side2 :|n quantity devices| |& " puts "&| $side3 :|time interval days| |& " puts "&| $side4 :|95 percentile=1.645, usual range 1,2,3*sigma | |&" puts "&| $side5 :|answers:MTBF in years | |&" puts "&| $side6 :|AFR annualized failure rate percent/year | |&" puts "&| $side7 :|average failures from prorated AFR over time interval| |&" puts "&| $spares :|unrounded spare formula from normal distribution | round up to higher integer|&" puts "&| $side8 :|required spares from normal distribution over time interval| rounded up |&" } frame .buttons -bg aquamarine4 ::ttk::button .calculator -text "Solve" -command { calculate } ::ttk::button .test2 -text "Testcase1" -command {clearx;fillup 100000. 45. 90. 1.645 11.4 8.76 0.972 2.59} ::ttk::button .test3 -text "Testcase2" -command {clearx;fillup 200000.0 45. 90. 1.645 22.83 4.38 0.486 1.633 } ::ttk::button .test4 -text "Testcase3" -command {clearx;fillup 300000.00 45. 90. 1.645 34.246 2.92 0.324 1.26 } ::ttk::button .clearallx -text clear -command {clearx } ::ttk::button .about -text about -command about ::ttk::button .self_help -text self_help -command { self_help } ::ttk::button .cons -text report -command { reportx } ::ttk::button .exit -text exit -command {exit} pack .calculator -in .buttons -side top -padx 10 -pady 5 pack .clearallx .cons .self_help .about .exit .test4 .test3 .test2 -side bottom -in .buttons grid .frame .buttons -sticky ns -pady {0 10} . configure -background aquamarine4 -highlightcolor brown -relief raised -border 30 wm title . "Spare Parts from Normal Distribution V2" # gold on TCL Club, 12Dec2018 ====== ---- ** Initial Console programs for spare parts function development ** ====== # pretty print from autoindent and ased editor # written on Windows XP on eTCL # working under TCL version 8.6.2 and_or eTCL 1.0.1 # gold on TCL WIKI, 5nov2014 # Console program for spare parts from normal distribution # using Tcl_Lib for trial solution from 1) normal 2) poisson # 3) other distributions and not picky. # The original solution used an inverse normal distribution (excel or cad function), # meaning finding x from a known cdf-normal probability (95 percent c.). package require Tk package require math::statistics namespace path {::tcl::mathop ::tcl::mathfunc} console show proc spare_parts {args} { foreach item $args { set assembly_case 45 set mtbfyears [/ $item 8760. ] set annual_failure [* [/ 1. $mtbfyears ] 100. ] set annual_failure_per_case [* $annual_failure $assembly_case 1.E-2] set spares_97c [* $annual_failure_per_case 2. ] set spares_97c_prorated_90_days [* $annual_failure_per_case 2. [/ 90. 365. ] ] set megaparts $item set spares_fraction [* $annual_failure_per_case 0.13 ] set spares_fraction2 [* $annual_failure_per_case 1. ] set spares_fraction6 [* $annual_failure_per_case 2. ] set spares_fraction10 [* $annual_failure_per_case 3. ] puts " design lifetime hours $megaparts 45 drives in assembly case \ trial spares for 97c on annual $spares_97c \ trial spares for 97c prorated for quarter year $spares_97c_prorated_90_days \ zap2 55c $spares_fraction zap3 84c $spares_fraction2 \ zap4 97c $spares_fraction6 zap5 99.9c spares_fraction10 \ zap6 annual failure percent $annual_failure \ annual failures per case ref 45 $annual_failure_per_case \n "}} spare_parts 100000. 200000. 300000. 700000. set bin { 100000. 200000. 300000. 700000. } puts " max number [math::statistics::max $bin] " puts " Console program for spare parts from normal distribution, check poisson " puts " The answer is x spare parts for large working inventory to 95% C. " puts " Note: Spare parts answers should be rounded up to nearest integer, especially not truncated." puts " pnorm number [ math::statistics::pnorm_quicker .95 ] " puts " 12 in_assembly 20 visit [ math::statistics::pdf-poisson 12 20 ] " puts " 12 in_assembly 20 more than 20 visitors=2.% [- 1. [ math::statistics::cdf-poisson 12 19 ] ]" puts " 45 in_assembly 41 success= still on line poisson [- 1. [ math::statistics::pdf-poisson 45 41 ] ]" puts " 45 in_assembly 43 success= still on line poisson [- 1. [ math::statistics::pdf-poisson 45 43 ] ]]" puts " 45 in_assembly 42 success= still on line poisson [- 1. [ math::statistics::pdf-poisson 45 42 ] ]]" puts " 45 in_assembly 43 success= still on line poisson [- 1. [ math::statistics::pdf-poisson 45 43 ] ]]" puts " 45 in_assembly 44 success= still on line poisson [- 1. [ math::statistics::pdf-poisson 45 44 ] ]]" ====== ---- ====== # pretty print from autoindent and ased editor # written on Windows XP on eTCL # working under TCL version 8.6.2 and_or eTCL 1.0.1 # gold on TCL WIKI, 5nov2014 # Console program for fuzzy round_up to next higher whole number # or rounding up next whole number towards infinity and beyond # positive numbers rounded up to positive infinity # negative numbers rounded nearest to negative infinity # whole numbers like 1 and 5 returned as floats of same value # fuzzy_round_up returns list of floating whole numbers package require Tk package require math::statistics package require math::decimal package require math::fuzzy namespace path {::tcl::mathop ::tcl::mathfunc} console show proc fuzzy_round_up {args } { set lister {} foreach item $args { if { $item > [int $item ] && $item > 0. } { lappend lister [+ [int $item ] 1.]} if { $item == [int $item ] } { lappend lister [* $item 1.] } if { $item < [int $item ] && $item < 0. } { lappend lister [+ [int $item ] -1.]} } return $lister } puts "fuzzy 5.87765544332 [+ [int 5.87765544332 ] 1.]" puts "fuzzy 5.00000000001 [+ [int 5.00000000001 ] 1.]" puts "fuzzy 5.99999999991 [+ [int 5.99999999991 ] 1.]" puts "fuzzy 5.00000000000 [+ [int 5.00000000000 ] 1.]" set positive " 5.87765544332 5.00000000001 5.99999999991 5.00000000000 5 " set negative " -5.87765544332 -5.00000000001 -5.99999999991 -5.00000000000 -5 " puts "fuzzy roundup < $positive > \n [ fuzzy_round_up 5.87765544332 5.00000000001 5.99999999991 5.00000000000 5 ] " puts "fuzzy roundup < $negative > \n [ fuzzy_round_up -5.87765544332 -5.00000000001 -5.99999999991 -5.00000000000 -5 ] " # fuzzy 5.87765544332 6.0 # fuzzy 5.00000000001 6.0 # fuzzy 5.99999999991 6.0 # fuzzy 5.00000000000 6.0 # fuzzy roundup < 5.87765544332 5.00000000001 5.99999999991 5.00000000000 5 > # 6.0 6.0 6.0 5.0 5.0 # fuzzy roundup < -5.87765544332 -5.00000000001 -5.99999999991 -5.00000000000 -5 > # -6.0 -6.0 -6.0 -5.0 -5.0 ====== ---- [gold] This page is copyrighted under the TCL/TK license terms, [http://tcl.tk/software/tcltk/license.html%|%this license]. **Comments Section** <> Please place any comments here, Thanks. <> Numerical Analysis | Toys | Calculator | Mathematics| Example| Toys and Games | Games | Application | GUI ---- <> Development | Concept| Algorithm| Statistics