Life Data Analysis in Microsoft Excel - Explanation: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
(Created page with '{{Template:APIClass|Repository Class| }} =Life Data Analysis in Microsoft Excel (Code Explanation)= This article explains some of the API calls in the [http://www.reliasoft.co…')
 
(Redirected page to API Tutorials)
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Template:APIClass|Repository Class| }}
#REDIRECT [[API_Tutorials]]
 
=Life Data Analysis in Microsoft Excel (Code Explanation)=
 
This article explains some of the API calls in the [http://www.reliasoft.com/synthesis/api/examples/WeibullExample.xlsm Life Data Analysis in Microsoft Excel] example file. For more examples, please see the [[Synthesis_API_Reference#Application_Examples|Example section]] of the API Reference.
 
==CalculateWeibull Subroutine==
 
First, we will walk through the CalculateWeibull subroutine:
 
<ol>
 
<li>Initialize a globally scoped WeibullDataSet object.  Note that this variable is declared outside the CalculateWeibull function so that it will be maintained later for use by the Plot subroutine.</li>
<li>Specify analysis settings.  Note that here we’re saying to run calculations using MLE to estimate parameters on a 2-parameter Weibull distribution. </li>
 
<li>Next we load the failures from the spreadsheet into the WeibullDataSet object.  To begin, we setup a loop to iterate through rows in the spreadsheet.  We begin the loop with 3 to skip over our two rows of headers.  We end the loop dynamically based on the last populated row of data.  This is accomplished by asking Excel to search upward from the last row in the sheet by calling <code>ActiveSheet.Cells(ActiveSheet.Rows.count, 1).End(xlUp).Row</code> to give the last row in the 1st column that has data entered into it.  Inside the loop, we call AddFailure to add the failure time and number in group for each of the rows on the spreadsheet. </li>
 
<li>Now that we’ve defined the WeibullDataSet, we call the data set’s calculate subroutine.  </li>
<li>After calculations are complete, we copy the parameters out of the WeibullDataSet object into the results section of the spreadsheet.  The parameters  are stored in the FittedModel inside the WeibullDataSet.  To begin, we pull out the ParamValues array that contains pairs of ParamName and Value.
 
Note that our spreadsheet only has 6 rows in a section called "Results."  Three of these rows will be taken up by the "Reliability," "Probability of Failure" and "Failure Rate" results.  This then leaves up to 3 rows available for any parameters contained in the FittedModel's ParamValues array, so we will ignore any additional parameters that might be in that array.
We define a variable called CurRow to iterate through the available spreadsheet rows (beginning with the first row below the “Results” header row).  We iterate through the ParamValues array and increment this variable as we read out up to 3 parameters.</li>
<li>Next we read the "At Time" and copy the results from the FittedModel's "Reliability," "Unreliability," and "FailureRate" functions to the results section of the sheet.</li>
 
</ol>
 
==Plot Subroutine==
 
After the WeibullDataSet is calculated, clicking the plot button will be able to update the plot region of the sheet. Upon clicking the Plot button, the Plot subroutine is called via the cmdPlot_Click handler.
Let’s walk through the Plot subroutine:
 
<ol>
<li>Check that the WeibullDataSet that will be referenced has been initialized.  If it hasn’t, then call the CalculateWeibull subroutine first so that we have something to plot. </li>
 
<li>Next we initialize a WAPlot object and add the WeibullDataSet.  Note that if the WeibullDataSet still isn’t initialized, then there is an error in the data set.  </li>
 
<li>Now that the WAPlot object has been initialized with the WeibullDataSet, we can get an image of a plot and display it in the spreadsheet’s plot image area.  Note that the GetSelectedPlotType function is called to translate the selected item in the spreadsheet list-box to a WAPlotType to be passed to the Plot object’s CreatePlotVB6 function. </li>
 
<li>If an error occurred, then we hide the plot image and display a message</li>
</ol>

Latest revision as of 21:17, 4 May 2016

Redirect to: