Skip to content

Commit

Permalink
mostly API docs for ALT fitters and adding a few other docs
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewReid854 committed Oct 7, 2021
1 parent 23e1981 commit 5b4c4a2
Show file tree
Hide file tree
Showing 8 changed files with 2,683 additions and 1,132 deletions.
8 changes: 8 additions & 0 deletions docs/How are the confidence intervals calculated.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. image:: images/logo.png

-------------------------------------

How are the confidence intervals calculated
'''''''''''''''''''''''''''''''''''''''''''

This is a placeholder for a theory document which will be written soon.
8 changes: 8 additions & 0 deletions docs/How are the plotting positions calculated.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. image:: images/logo.png

-------------------------------------

How are the plotting positions calculated
'''''''''''''''''''''''''''''''''''''''''

This is a placeholder for a theory document which will be written soon.
8 changes: 8 additions & 0 deletions docs/How does Least Squares Estimation work.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. image:: images/logo.png

-------------------------------------

How does Least Squares Estimation work
''''''''''''''''''''''''''''''''''''''

This is a placeholder for a theory document which will be written soon.
8 changes: 8 additions & 0 deletions docs/How does Maximum Likelihood Estimation work.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. image:: images/logo.png

-------------------------------------

How does Maximum Likelihood Estimation work
'''''''''''''''''''''''''''''''''''''''''''

This is a placeholder for a theory document which will be written soon.
9 changes: 6 additions & 3 deletions docs/Optimizers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
Optimizers
''''''''''

**What is an optimizer?**
What is an optimizer?
"""""""""""""""""""""

An optimizer is an algorithm that uses two primary inputs; a target function and an initial guess. The optimizer's job is to figure out which input to the target function will minimise the output of the target function.

Expand Down Expand Up @@ -40,13 +41,15 @@ The optimizer that was used is always reported by each of the functions in `Fitt
BIC 19.3294
AD 3.72489
**Why do we need different optimizers?**
Why do we need different optimizers?
""""""""""""""""""""""""""""""""""""
Each optimizer has various strengths and weaknesses because they work in different ways. Often they will arrive at the same result. Sometimes they will arrive at different results, either because of the very shallow gradient near the minimum, or the non-global minimum they have found. Sometimes they will fail entirely.
There is no single best optimizer for fitting probability distributions so a few options are provided as described below.
**Which optimizer should I pick?**
Which optimizer should I pick?
""""""""""""""""""""""""""""""
You don't really need to worry about picking an optimizer as the default choice is usually sufficient. If you do want to select your optimizer, you have four to choose from. Most importantly, you should be aware of what the optimizer is doing (minimizing the negative log-likelihood equation by varying the parameters) and understand that optimizers aren't all the same which can cause different results. If you really need to know the best optimizer then select "best", otherwise you can just leave the default as None.
Expand Down
11 changes: 10 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Contents:
:caption: Parametric Models

Equations of supported distributions
What is censored data
Creating and plotting distributions
Fitting a specific distribution to data
Fitting all available distributions to data
Expand Down Expand Up @@ -117,6 +116,16 @@ Contents:
Distribution explorer
Histogram

.. toctree::
:maxdepth: 1
:caption: Reliability Theory

What is censored data
How are the plotting positions calculated
How does Least Squares Estimation work
How does Maximum Likelihood Estimation work
How are the confidence intervals calculated

.. toctree::
:maxdepth: 1
:caption: Administration
Expand Down
3,741 changes: 2,619 additions & 1,122 deletions reliability/ALT_fitters.py

Large diffs are not rendered by default.

22 changes: 16 additions & 6 deletions reliability/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3674,9 +3674,14 @@ def linear_regression(
raise ValueError(err_str)

if RRX_or_RRY == "RRY":
solution = (
np.linalg.inv(xx.T.dot(xx)).dot(xx.T).dot(yy)
) # linear regression formula for RRY
try:
solution = (
np.linalg.inv(xx.T.dot(xx)).dot(xx.T).dot(yy)
) # linear regression formula for RRY
except LinAlgError:
raise RuntimeError(
"An error has occurred when attempting to find the initial guess using least squares estimation.\nThis error is caused by a non-invertable matrix.\nThis can occur when there are only two very similar failure times like 10 and 10.000001.\nThere is no solution to this error, other than to use failure times that are more unique."
)
if y_intercept is not None:
m = solution[0]
c = y_intercept
Expand All @@ -3687,9 +3692,14 @@ def linear_regression(
m = solution[0]
c = solution[1]
else: # RRX
solution = (
np.linalg.inv(yy.T.dot(yy)).dot(yy.T).dot(xx)
) # linear regression formula for RRX
try:
solution = (
np.linalg.inv(yy.T.dot(yy)).dot(yy.T).dot(xx)
) # linear regression formula for RRX
except LinAlgError:
raise RuntimeError(
"An error has occurred when attempting to find the initial guess using least squares estimation.\nThis error is caused by a non-invertable matrix.\nThis can occur when there are only two very similar failure times like 10 and 10.000001.\nThere is no solution to this error, other than to use failure times that are more unique."
)
if x_intercept is not None:
m_x = solution[0]
m = 1 / m_x
Expand Down

0 comments on commit 5b4c4a2

Please sign in to comment.