> #The first four lines invoke Maple Command libraries used in the rest of the code and are necessary for the correct execution of the code. > with(Statistics) Warning, the name Rank has been rebound > with(plots) Warning, the previous binding of the name Interactive has been removed and it now has an assigned value > with(LinearAlgebra): Warning, the names LeastSquares and Rank have been rebound > with(CurveFitting) Warning, the name LeastSquares has been rebound > #The first portion of code performs the one-sample comparison of the mean residual life function to a baseline. > #The following line imports data from a text file that is tab delimited. See Maple's Help files for ways to import other kinds of files. For correct operation, all failures in the data should take place when thte stress is greater than zero and a zero should be added to the data so the mean residual life function will be computed at stress=0. > x := ImportMatrix("48density.txt", delimiter = "\\t") > #Some data manipulation steps are easier to make when data is defined in a certain way in Maple. The next line converts the original data a list so the \"sort\" command may be used. > p:=convert(x,list): > > q:=sort(p): > #In preparation for later mathematical operations, the list is converted to an array. > t := Array(q) > > #c sets the number of rows that will be in the matrix where calculations of the standard errors, mean residual life, etc. will be calculated. Because the first row will represent stress=0, the sample size is c-1. a is a counting variable. The number of columns in the matrix,K, are predefined based on the number of calculations that will be recorded. In this case, the seven columns are: 1. row number, 2. mean residual life, 3. standard error of the sample used to calculate the mean residual life, 4. sample size, 5. stress level for each failure, 6. z-value at beginning of failure stress interval, 7. z-value at end of failure stress interval. > #for ease of checking, some lines end in a semi-colon. In Maple, lines that end in a colon do not display their result when the code is running and lines that end in semi-colons do. Occassionally lines are inserted specifically to provide an opportunity to check a value. > c := ArrayNumElems(t) c := 109 > a := 1 > K := Matrix(c, 7) > #The 4 lines below are redone in the loop below, but are provided here as simple examples of the second, third, and fourth columns. m takes the positive values of t, which is our original data. Here, m is all the failure times. Inside the actual loop, m takes the values of the times remaining after the time of the most recent failure. > m := Select(proc (y) options operator, arrow; is(0 < y) end proc, t) > K[a, 4] := c-1 > K[a, 3] := StandardDeviation(m) > K[a, 2] := Mean(m) > a 1 > #This loop writes the remaining mean residual lives, standard errors, and sample sizes for the samples after each failure. > for a to c do r := t-t[a]; m := Select(proc (y) options operator, arrow; is(0 < y) end proc, r); if 1 < ArrayNumElems(m) then K[a, 3] := StandardDeviation(m) end if; if 0 < ArrayNumElems(m) then K[a, 2] := Mean(m) end if; K[a, 4] := c-a end do > K[1, 4] 108 > > #This loop writes the failure times into the matrix K. > counter2 := 1 > for counter2 to c do K[counter2, 5] := t[counter2] end do > #In cases where more than one individual fails at the same stress, the mean residual life function only takes one value. The following loop counts the number of ties so that the correct value-the one that considers all the failures that take place at a stress level-can be left in the matrix, K. > nties := 0 > for counter4 to c-1 do if K[counter4, 5] = K[counter4+1, 5] then nties := nties+1 end if end do > nties > > counter3 := 1 > #The following loop removes rows that are not needed because of tied failure stresses. > for counter3 to c-nties-1 do if K[counter3, 5] = K[counter3+1, 5] then K := DeleteRow(K, counter3); counter3 := counter3-1 end if end do > #The new number of rows after the tied rows have been deleted is defined below as \"Krows.\" > Krows := c-nties > > #The next loop adds row numbers to matrix K for identification numbers. Although positioned in the first column of the matrix, it needs to be added at the end after the tied rows are deleted to make sense. > counter7 := 1 > for counter7 to Krows do K[counter7, 1] := counter7 end do > #The baseline may be chosen as any number desired. The code has not been tested with the baseline defined as a function, but this may be possible. > baseline := 80 > #The loop below computes a z-score for the mean residual life function vs. the baseline. This is the one sample procedure defined in Part 4 of the thesis. > counter5 := 1 > for counter5 to Krows-2 do K[counter5, 6] := (K[counter5, 2]-baseline)/(K[counter5, 3]^2/K[counter5, 4])^.5 end do > #The loop below checks the endpoint of the z-function for the mean residual life function vs. the baseline. When the z-score for the desired confidence level is between the end point and the z-score we can find the mean residual life function \"function domain sets\" confidence interval endpoint. These steps follow the loop below. > counter6 := 1 > > for counter6 to Krows-2 do K[counter6, 7] := K[counter6, 6]+(K[counter6, 5]-K[counter6+1, 5])/(K[counter6, 3]^2/K[counter6, 4])^.5 end do > > #Desired confidence levels may be manipulated as desired. Three are provided, so different levels can be compared as useful. > > desiredconfidence1 := 90 > desiredconfidence2 := 95 > desiredconfidence3 := 99 > #Note that z-values for confidence are for, in this case, one-sided confidence intervals. Adjustments should be made in the \"desiredconfidence\" variables above if a two-sided interval is of interest. > zalpha1 := Percentile(Normal(0, 1), desiredconfidence1, numeric) zalpha1 := 1.281551566 > zalpha2 := Percentile(Normal(0, 1), desiredconfidence2, numeric) zalpha2 := 1.644853627 > > zalpha3 := Percentile(Normal(0, 1), desiredconfidence3, numeric) zalpha3 := 2.326347874 > #The loop below finds the interval where the MRL z-score function crosses the z-value of the desired confidence level. Immediately below, the failure time is interpolated that gives the upper bound of the \"function domain sets\" confidence interval. > counter8 := 1 > for counter8 to Krows do if K[counter8, 7] < zalpha1 and zalpha1 < K[counter8, 6] then interpolaterow1 := counter8; counter8 := counter8+Krows end if end do > interpolaterow1 > #The lines below provide the upper end of the calculated \"function domain sets\" confidence intervals. These are not output to the matrix, but are the main output of this portion of the code. > upper90 := PolynomialInterpolation([[K[interpolaterow1, 6], K[interpolaterow1, 5]], [K[interpolaterow1, 7], K[interpolaterow1+1, 5]]], zalpha1) upper90 := 103.9752291 > for counter8 to Krows do if K[counter8, 7] < zalpha2 and zalpha2 < K[counter8, 6] then interpolaterow2 := counter8; counter8 := counter8+Krows end if end do > upper95 := PolynomialInterpolation([[K[interpolaterow2, 6], K[interpolaterow2, 5]], [K[interpolaterow2, 7], K[interpolaterow2+1, 5]]], zalpha2) upper95 := 103.4875929 > for counter8 to Krows do if K[counter8, 7] < zalpha3 and zalpha3 < K[counter8, 6] then interpolaterow3 := counter8; counter8 := counter8+Krows end if end do > upper99 := PolynomialInterpolation([[K[interpolaterow3, 6], K[interpolaterow3, 5]], [K[interpolaterow3, 7], K[interpolaterow3+1, 5]]], zalpha3) upper99 := 102.5728684 > #This file may be renamed. It contains the numbers saved in matrix K as described earlier. > ExportMatrix("first.xls", K) > #The following lines of code repeat those previously for a second data sample. As before, zero should be entered into a data set of failure times so that the MRL function will be correctly computed beginning from the stress=0 point. > x2 := ImportMatrix("46density.txt", delimiter = "\\t") > p2:=convert(x2,list): > > q2:=sort(p2): > t2 := Array(q2) > > > c2 := ArrayNumElems(t2) c2 := 975 > a2 := 1 > K2 := Matrix(c2, 7) > m2 := Select(proc (y) options operator, arrow; is(0 < y) end proc, t2) > K2[a2, 4] := c2-1 K2[1, 4] := 974 > K2[a2, 3] := StandardDeviation(m2) > K2[a2, 2] := Mean(m2) > > for a2 to c2 do r2 := t2-t2[a2]; m2 := Select(proc (y) options operator, arrow; is(0 < y) end proc, r2); if 1 < ArrayNumElems(m2) then K2[a2, 3] := StandardDeviation(m2) end if; if 0 < ArrayNumElems(m2) then K2[a2, 2] := Mean(m2) end if; K2[a2, 4] := c2-a2 end do > K2[1, 4] 974 > counter2 := 1 > for counter2 to c2 do K2[counter2, 5] := t2[counter2] end do > > nties2 := 0 > for counter4 to c2-1 do if K2[counter4, 5] = K2[counter4+1, 5] then nties2 := nties2+1 end if end do > nties2 627 > > counter3 := 1 > for counter3 to c2-nties2-2 do if K2[counter3, 5] = K2[counter3+1, 5] then K2 := DeleteRow(K2, counter3); counter3 := counter3-1 end if end do > Krows2 := c2-nties2 Krows2 := 348 > > counter7 := 1 > > for counter7 to Krows2 do K2[counter7, 1] := counter7 end do > baseline2 := 80 > counter5 := 1 > for counter5 to Krows2-2 do K2[counter5, 6] := (K2[counter5, 2]-baseline2)/(K2[counter5, 3]^2/K2[counter5, 4])^.5 end do > > counter6 := 1 > > for counter6 to Krows2-2 do K2[counter6, 7] := K2[counter6, 6]+(K2[counter6, 5]-K2[counter6+1, 5])/(K2[counter6, 3]^2/K2[counter6, 4])^.5 end do > counter7 := 1 > for counter7 to Krows2 do K2[counter7, 1] := counter7 end do > > desiredconfidence1b := 90 > desiredconfidence2b := 95 > desiredconfidence3b := 99 > zalpha1b := Percentile(Normal(0, 1), desiredconfidence1b, numeric) zalpha1b := 1.281551566 > zalpha2b := Percentile(Normal(0, 1), desiredconfidence2b, numeric) zalpha2b := 1.644853627 > > zalpha3b := Percentile(Normal(0, 1), desiredconfidence3b, numeric) zalpha3b := 2.326347874 > counter8 := 1 > for counter8 to Krows2 do if K2[counter8, 7] < zalpha1b and zalpha1b < K2[counter8, 6] then interpolaterow1b := counter8; counter8 := counter8+Krows2 end if end do > interpolaterow1b > upper90b := PolynomialInterpolation([[K2[interpolaterow1b, 6], K2[interpolaterow1b, 5]], [K2[interpolaterow1b, 7], K2[interpolaterow1b+1, 5]]], zalpha1b) upper90b := 42.31469156 > for counter8 to Krows2 do if K2[counter8, 7] < zalpha2b and zalpha2b < K2[counter8, 6] then interpolaterow2b := counter8; counter8 := counter8+Krows2 end if end do > upper95b := PolynomialInterpolation([[K2[interpolaterow2b, 6], K2[interpolaterow2b, 5]], [K2[interpolaterow2b, 7], K2[interpolaterow2b+1, 5]]], zalpha2b) upper95b := 42.19533335 > for counter8 to Krows2 do if K2[counter8, 7] < zalpha3b and zalpha3b < K2[counter8, 6] then interpolaterow3b := counter8; counter8 := counter8+Krows2 end if end do > upper99b := PolynomialInterpolation([[K2[interpolaterow3b, 6], K2[interpolaterow3b, 5]], [K2[interpolaterow3b, 7], K2[interpolaterow3b+1, 5]]], zalpha3b) upper99b := 41.97143715 > ExportMatrix("second.xls", K2) > #This begins the portion that explores the two-sample case, using the data from the matrices named K and K2 in the code. To begin with, the data from those two matrices are combined into a single matrix. The number of rows for the new matrix are determined immediately below and then the new matrix is defined on the next line. The number of columns for the new matrix, 11, is fixed based on the information that will be recorded in the new matrix. > twosamprows := Krows+Krows2 twosamprows := 448 > twosamp := Matrix(twosamprows, 11) > countera := 1 > counterb := 1 > #This loop enters the failure stress values from the first imported data set from the matrix named K into the first column of the two-sample matrix. It also enters the two-sample z-value for the failure times present in the first column from the first data set. Both values will be reordered for presentation. > for countera to Krows do twosamp[countera, 1] := K[countera, 5]; if K2[Krows2, 5] < K[countera, 5] then counterb := Krows2+1 elif K[countera, 5] < K2[Krows2, 5] then counterb := 1; while K2[counterb, 5] <= K[countera, 5] do counterb := counterb+1 end do end if; if K[countera, 4] = 0 or K2[counterb-1, 4] = 0 or K[countera, 3] = 0 and K2[counterb-1, 3] = 0 then twosamp[countera, 2] := 0 else twosamp[countera, 2] := (K[countera, 2]-(K2[counterb-1, 2]-K[countera, 5]))/sqrt(K[countera, 3]^2/K[countera, 4]+K2[counterb-1, 3]^2/K2[counterb-1, 4]) end if end do > counterb 349 > countera 101 > counterc := countera counterc := 101 > counterd := 1 counterd := 1 > countere := 1 countere := 1 > #The loop below enters the failure stresses from the second data set, matrix K2. It also calculates and enters the two-sample z-values for the failure stress values from the second data set. Both values will be reordered for presentation. > for counterc from countera to twosamprows do twosamp[counterc, 1] := K2[counterd, 5]; if K[Krows, 5] < K2[counterd, 5] then countere := Krows+1 else countere := 1; while K[countere, 5] <= K2[counterd, 5] do countere := countere+1 end do end if; if K2[counterd, 4] = 0 or K[countere-1, 4] = 0 or K2[counterd, 3] = 0 and K[countere-1, 3] = 0 then twosamp[counterc, 2]; 0 else twosamp[counterc, 2] := ((K[countere-1, 2]-K2[counterd, 5])-K2[counterd, 2])/sqrt(K2[counterd, 3]^2/K2[counterd, 4]+K[countere-1, 3]^2/K[countere-1, 4]) end if; counterd := counterd+1 end do > > counterc 449 > counterd 349 > #The next four lines order the combined failure times from the two data sets. These will be put in the third column of the matrix in the next loop. > failures := Column(twosamp, 1) > fail := convert(failures, list) > fails := sort(fail) > failu := Array(fails) > > > > counterf := 1 counterf := 1 > for counterf to twosamprows do twosamp[counterf, 3] := failu[counterf] end do > counterg := 1 > counterf := 1 > printlevel := 4 printlevel := 4 > #The loop below matches the unordered z-values from earlier with the correct failure value and prints them in the fourth column of the matrix. > for counterg to twosamprows do counterg; counterf := 1; if twosamp[counterg, 1] = twosamp[counterf, 3] then twosamp[counterf, 4] := twosamp[counterg, 2] else while twosamp[counterf, 3] <= twosamp[counterg, 1] and counterf < twosamprows do counterf := counterf+1 end do; twosamp[counterf-1, 4] := twosamp[counterg, 2] end if end do > #The next loop ensures that any cases where the failure times are the same have the same z-value. > counterf > if twosamp[1, 3] = twosamp[2, 3] then twosamp[2, 4] := twosamp[1, 4] end if twosamp[2, 4] := 45.56163144 > counterg > #The loop below repeats checking that any cases where the failure times are the same have the same z-value. > counterz := 1 > for counterz to counterg-2 do if twosamp[counterz, 3] = twosamp[counterz+1, 3] then twosamp[counterz, 4] := twosamp[counterz+1, 4] end if end do twosamp[1, 4] := 45.56163144 > #The next loop takes the number surviving from the first data set and puts them into the new matrix in the fifth column. > counteraa := 1 > for counteraa to Krows do twosamp[counteraa, 5] := K[counteraa, 4] end do > counterbb := Krows+1 > #The next loop places the number surviving in column 6 of the new matrix beginning in the row after the last number surviving from the first data set. > countercc := 1 > for counterbb from Krows+1 to twosamprows do twosamp[counterbb, 6] := K2[countercc, 4]; countercc := countercc+1 end do > countergg := 1 > counterff := 1 > #The row below puts the number surviving from the first data into the seventh column set for the ordered survival times in the third column. These will be compared to the number surviving for the second data set (placed in the eighth column) to determine the degrees of freedom for the two-sample t-statistic. > for countergg to Krows do counterff := 1; if twosamp[countergg, 3] = twosamp[countergg, 1] then twosamp[counterff, 7] := twosamp[countergg, 5] else while twosamp[counterff, 3] <= twosamp[countergg, 1] and counterff <= twosamprows do counterff := counterff+1 end do; twosamp[counterff-1, 7] := twosamp[countergg, 5] end if end do Error, Matrix index out of range > counterdd := 1 > counteree := Krows+1 > #The next loop places the number surviving from the second data set into the eighth column that correspond to the ordered survival times in the third column. > for counteree from Krows+1 to twosamprows do counterdd := 1; if twosamp[counterdd, 3] = twosamp[counteree, 1] then twosamp[counterdd, 8] := twosamp[counteree, 6] else while twosamp[counterdd, 3] <= twosamp[counteree, 1] and counterdd <= twosamprows do counterdd := counterdd+1 end do; twosamp[counterdd-1, 8] := twosamp[counteree, 6] end if end do > #The next loop makes corrections to sample sizes so that the number surviving is shown correctly at the top of the matrix where there are two zero times, since each data set had one initially. > counterhh := 1 > for counterhh to twosamprows do if twosamp[counterhh, 7] = 0 and twosamp[counterhh, 8] = 0 and twosamp[counterhh, 3] = 0 then twosamp[counterhh, 7] := twosamp[counterhh-1, 7]; twosamp[counterhh, 8] := twosamp[counterhh-1, 8] end if end do twosamp[2, 7] := 108 twosamp[2, 8] := 974 > counterii := 1 > for counterii to twosamprows-1 do if twosamp[counterii, 7] = 0 and twosamp[counterii, 8] = 0 then twosamp[counterii, 7] := twosamp[counterii+1, 7]; twosamp[counterii, 8] := twosamp[counterii+1, 8] end if end do twosamp[447, 7] := 0 twosamp[447, 8] := 0 > #The loop below makes corrections to columns where a zero number surviving was left because no failure time matched for that column. The line immediately afterwards corrects where the zero is overwritten that should belong there. > counterjj := 1 > twosamp[Krows, 1] 219.6999969 > for counterjj to twosamprows do if twosamp[counterjj, 7] = 0 and twosamp[counterjj, 3] < twosamp[twosamprows, 1] then twosamp[counterjj, 7] := twosamp[counterjj-1, 7] end if; if twosamp[counterjj, 8] = 0 and twosamp[twosamprows, 1] < twosamp[Krows, 1] then twosamp[counterjj, 8] := twosamp[counterjj-1, 8] end if end do > > twosamp[twosamprows, 8] = 0 > #This loop calculates the t statistic that is appropriate for comparison to the t-score of the two-sample confidence level of interest. This alerts the user to cases where differences may appear large but are not statisitically significant because of small sample sizes. Here, the confidence level is 99 `%`, but this may be adjusted at the convenience of the user. > counterkk := 1 > for counterkk to twosamprows do tdf := min(twosamp[counterkk, 8], twosamp[counterkk, 7]); if 1 < tdf then twosamp[counterkk, 9] := Percentile(StudentT(tdf-1), 99, numeric) end if end do > #A matrix is output here with the information that has been calculated for the two sample case. > ExportMatrix("check.xls", twosamp) > #A new matrix is created that should neatly output all the numbers calculated in the previous code. A new row is added so that column labels can be added. At the end, it is output as a Microsfot Excel file. See Maple's help for directions on outputting to other types of files. > outputmatrix := Matrix(twosamprows+1, 11) > outputmatrix[1, 1] := "unordered failure times" > outputmatrix[1, 2] := "unordered z scores" > outputmatrix[1, 3] := "failure times" > outputmatrix[1, 4] := "z scores" > outputmatrix[1, 5] := "unordered number surviving from sample1" > outputmatrix[1, 6] := "unordered number surviving until, sample 2" > outputmatrix[1, 7] := "number surviving until, sample 1" > outputmatrix[1, 8] := "number surviving until, sample 2" > outputmatrix[1, 9] := "t scores" > outputmatrix[1, 10] := "mrl, sample 1" > outputmatrix[1, 11] := "mrl, sample 2" > outputcounter := 1 > outcounter := 2 > for outputcounter to 9 do for outcounter from 2 to twosamprows do outputmatrix[outcounter, outputcounter] := twosamp[outcounter-1, outputcounter] end do end do > ocounter := 1 > pcounter := 1 > printlevel := 1 > #Not included in the \"check\" matrix, the next loop adds the MRL values to the \"output\" Microsoft Excel file. > for ocounter to twosamprows do for pcounter to Krows do if outputmatrix[ocounter, 7] = K[pcounter, 4] then outputmatrix[ocounter, 10] := K[pcounter, 2] end if end do end do > ocounter := 1 > pcounter := 1 > for ocounter to twosamprows do for pcounter to Krows2 do if outputmatrix[ocounter, 8] = K2[pcounter, 4] then outputmatrix[ocounter, 11] := K2[pcounter, 2] end if end do end do > ExportMatrix("output.xls", outputmatrix) 41855 > #Calculations for the two sample confidence intervals are prepared below. The desired confidence levels may be adjusted as desired by the user. > desiredtwosampconfidencea := 90 > desiredtwosampconfidenceb := 95 > desiredtwosampconfidencec := 99 > zalphatsa := Percentile(Normal(0, 1), desiredtwosampconfidencea, numeric) zalphatsa := 1.281551566 > zalphatsb := Percentile(Normal(0, 1), desiredtwosampconfidenceb, numeric) zalphatsb := 1.644853627 > > zalphatsc := Percentile(Normal(0, 1), desiredtwosampconfidencec, numeric) zalphatsc := 2.326347874 > twosampa := 1 > counterh := 1 > #The loop below finds where the two-sample z-function crosses the desired confidence level z-value and saves it as the row number as the variable \"twosampa.\" Immediately afterwards, linear interpolation is used to find the endpoint of the \"function domain sets\" confidence interval for which the greater MRL function dominates the lower one. The process is repeated for for the remaining two confidence levels. > for counterh to twosamprows do if twosamp[counterh, 4] < zalphatsa then twosampa := counterh; counterh := counterh+twosamprows end if end do > twosampa 344 > upper90ts := PolynomialInterpolation([[twosamp[twosampa-1, 4], twosamp[twosampa-1, 3]], [twosamp[twosampa, 4], twosamp[twosampa, 3]]], zalphatsa) upper90ts := 147.4675343 > > for counterh to twosamprows do if twosamp[counterh, 4] < zalphatsb then twosampb := counterh; counterh := counterh+twosamprows end if end do > twosampb 343 > upper95ts := PolynomialInterpolation([[twosamp[twosampb-1, 4], twosamp[twosampb-1, 3]], [twosamp[twosampb, 4], twosamp[twosampb, 3]]], zalphatsb) upper95ts := 147.3940803 > for counterh to twosamprows do if twosamp[counterh, 4] < zalphatsc then twosampc := counterh; counterh := counterh+twosamprows end if end do > twosampc 342 > upper99ts := PolynomialInterpolation([[twosamp[twosampc-1, 4], twosamp[twosampc-1, 3]], [twosamp[twosampc, 4], twosamp[twosampc, 3]]], zalphatsa) upper99ts := 147.9844381 > The next lines repeat the confidence interval process with the t distribution instead of with the normal distribution, to check for any problems with sample size making the z-confidence intervals less useful. > for counterh to twosamprows do if twosamp[counterh, 4] < twosamp[counterh, 9] then twosamp99student := counterh; counterh := counterh+twosamprows end if end do > twosamp99student 341 > > upper99tint := PolynomialInterpolation([[twosamp[twosamp99student-1, 4], twosamp[twosamp99student-1, 3]], [twosamp[twosamp99student, 4], twosamp[twosamp99student, 3]]], twosamp[twosamp99student, 9]) upper99tint := 146.4622854 > #Vectors are declared below to use in plots of the results from the code above. For those interested in the Maple code process used, "failweight" and "tvals" are declared first to make the failure times and t values into vectors. Each is then converted into a list so that they can easily be changed into a single vector of points, below named "fbys3b." A similar process creates a vector of points with the MRL function values. > failweight := Column(twosamp, 3) > tvals := Column(twosamp, 9) > failweightlist := convert(failweight, list) > tvalslist := convert(tvals, list) > for i to twosamprows do fbys3b[i] := [failweightlist[i], tvalslist[i]] end do > twosampzvals := Column(twosamp, 4) > mrl1 := Column(K, 2) > mrl1list := convert(mrl1, list) > mrl1fails := Column(K, 5) > mrl1failslist := convert(mrl1fails, list) > for i to Krows do failbymrl1[i] := [mrl1failslist[i], mrl1list[i]] end do > failbymrl1list := convert(failbymrl1, list) > mrl2 := Column(K2, 2) > mrl2fails := Column(K2, 5) > for i to Krows2 do failbymrl2[i] := [mrl2fails[i], mrl2[i]] end do > failbymrl2list := convert(failbymrl2, list) > #A number of plots are demonstrated below, some to suggest variations of plots that may be useful in Maple. Polynomial interpolation is also demonstrated as a means of solving for the mean residual life function value at a specific stress level. > #This is a simple plot in maple that shows the MRL values of the second sample data. > pointplot(failbymrl2list) > #Polynomial interpolation is demonstrated below. \"w\" has not been declared as a variable previously. > blue := PolynomialInterpolation(failbymrl1list, w) 95 40 156 blue := -4.355651700 10 w + 3.366153627 10 w + 185.6953707 147 11 156 2 151 7 + 1.017954633 10 w - 1.786100327 10 w + 8.918483747 10 w 154 5 153 6 149 9 + 1.044583346 10 w - 1.063024039 10 w + 3.905593583 10 w 148 10 150 8 87 44 - 2.113613919 10 w - 6.344116742 10 w - 1.367247886 10 w 142 14 144 13 145 12 - 6.187208592 10 w + 1.728639393 10 w - 4.406617164 10 w 89 43 141 15 139 16 + 1.943850351 10 w + 2.032334020 10 w - 6.156965917 10 w 135 19 136 18 138 17 + 1.097232056 10 w - 4.507956220 10 w + 1.727757157 10 w 130 22 131 21 84 45 - 1.072189576 10 w + 5.337860908 10 w + 9.229891273 10 w 133 20 155 3 154 4 - 2.498707339 10 w + 4.689942180 10 w - 8.124776736 10 w 128 23 82 46 122 26 + 2.029284363 10 w - 5.981245111 10 w - 9.804510800 10 w 124 25 93 41 126 24 + 6.126438601 10 w + 3.470457431 10 w - 3.625819856 10 w 115 30 117 29 119 28 - 3.837003252 10 w + 2.940821967 10 w - 2.145454717 10 w 121 27 55 58 113 31 + 1.488249946 10 w - 1.381435781 10 w + 4.769992890 10 w 101 37 103 36 105 35 + 6.675012900 10 w - 7.059438078 10 w + 7.144776753 10 w 107 34 109 33 111 32 - 6.916064942 10 w + 6.398943518 10 w - 5.655057491 10 w 99 38 50 60 52 59 - 6.043108584 10 w - 1.927674948 10 w + 5.269494035 10 w 97 39 47 61 45 62 + 5.240821436 10 w + 6.760497011 10 w - 2.272157421 10 w 42 63 11 75 5 77 + 7.315247986 10 w + 2.524586727 10 w + 7.104446369 10 w 8 76 79 78 - 4.355026591 10 w + 1.587673586 w - 1094.112635 w 32 67 30 68 27 69 + 5.061542342 10 w - 1.303801855 10 w + 3.205475972 10 w 24 70 40 64 37 65 - 7.515665647 10 w - 2.254998115 10 w + 6.652180347 10 w 35 66 57 57 59 56 - 1.876868845 10 w + 3.474149145 10 w - 8.383681351 10 w 80 47 64 54 71 51 + 3.721327324 10 w - 4.317010276 10 w + 3.717320635 10 w 73 50 62 55 69 52 - 7.026155904 10 w + 1.941717491 10 w - 1.888694644 10 w 78 48 76 49 66 53 - 2.223136163 10 w + 1.275358223 10 w + 9.214917145 10 w 22 71 19 72 16 73 + 1.678977154 10 w - 3.570232251 10 w + 7.218623036 10 w 14 74 80 81 - 1.386136851 10 w - 0.002166273464 w + 0.000002772686165 w -9 82 -12 83 -15 84 - 3.320371627 10 w + 3.709325376 10 w - 3.852872771 10 w -18 85 -21 86 -24 87 + 3.706970857 10 w - 3.289466747 10 w + 2.678812474 10 w -27 88 -30 89 -34 90 - 1.990448353 10 w + 1.340238946 10 w - 8.111258442 10 w -37 91 -40 92 -44 93 + 4.368767766 10 w - 2.068487905 10 w + 8.475851620 10 w -47 94 -51 95 -54 96 - 2.944737000 10 w + 8.434478840 10 w - 1.912224835 10 w -58 97 -62 98 -66 99 + 3.217421948 10 w - 3.571577342 10 w + 1.962015788 10 w 91 42 - 2.651837104 10 w > whattype(blue) + > #The line below demonstrates solving for a specific value of the MRL function with polynomial interpolation. The second value is the stress value where the desired value lies. > blue2 := PolynomialInterpolation(failbymrl2list, 0) blue2 := 122.7357289 > #The plot from above is repeated here with the connect=true option. This option tends to be more common in graphs of MRL functions and stresses that the function is often assumed to be continuous. Below is the plot of the first sample's MRL function. > pointplot(failbymrl2list, connect = true) > > pointplot(failbymrl1list, connect = true) > whattype(failbymrl) symbol > fbys3bl := convert(fbys3b, list) > #Below is a point plot of the calculated t-values by stress level based on the minimum surviving from the two samples. At the end, the function has been forced to be zero. Infinite or Does Not Exist would be more technically correct, but are not convenient for plotting. > pointplot(fbys3bl) > > #lists of points are created below for the zfunction and for z-scores for the 99 `%` confidence level. > twosampzvalslist := convert(twosampzvals, list) > for i to twosamprows do failbyz[i] := [failweightlist[i], twosampzvalslist[i]] end do > failbyzlist := convert(failbyz, list) > for i to twosamprows do ztest[i] := [failweightlist[i], zalphatsc] end do > ztestlist := convert(ztest, list) > for i to twosamprows do negztest[i] := [failweightlist[i], -zalphatsc] end do > negztestlist := convert(negztest, list) > #A multiple point plot is demonstrated below containing the two MRL functions. Color options are also demonstrated. See Maple's help for a complete list of available colors. > multiple(pointplot, [failbymrl1list, color = black, connect = true], [failbymrl2list, color = orange, connect = true]) > > for i to twosamprows do negfbys3b[i] := [failweightlist[i], -tvalslist[i]] end do > negfbys3blist := convert(negfbys3b, list) > > #More complicated plots are below that includes multiple functions. Line thickness options and line style options are demonstrated. Plot title and axis labels are also included. > multiple(pointplot, [negztestlist, connect = true, linestyle = DASH], [ztestlist, connect = true, linestyle = DASH], [fbys3bl, connect = true, linestyle = DOT], [failbyzlist, connect = true, thickness = 2], [failbymrl1list, connect = true, thickness = 1], [failbymrl2list, connect = true, thickness = 1], [negfbys3blist, connect = true, linestyle = DOT], title = "Mean Residual Life Functions, Z Function, and 't' Critical Values", labels = [indepaxis, depaxis], labeldirections = [horizontal, vertical]) > multiple(pointplot, [failbymrl1list, connect = true, thickness = 1], [failbymrl2list, connect = true, thickness = 1], title = "Mean Residual Life Functions", labels = [indepaxis, depaxis], labeldirections = [horizontal, vertical]) > multiple(pointplot, [failbyzlist, connect = true, thickness = 2], [ztestlist, connect = true], [failbymrl1list, connect = true, thickness = 1], [failbymrl2list, connect = true, thickness = 1], title = "Mean Residual Life Functions and Z Function", labels = [indepaxis, depaxis], labeldirections = [horizontal, vertical]) > #This final plot shows the gridlines option in a plot. > multiple(pointplot, [failbymrl1list, thickness = 1], [failbymrl2list, color = red], gridlines) >