Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkLinkModels.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include <mitkLinkModels.h>
14 #include <cmath>
15 #include <limits>
16 
18 {
19  lowerBound = std::log( std::numeric_limits<double>::epsilon());
20  upperBound = -lowerBound;
21 }
22 
23 double mitk::LogItLinking::Link(double mu)
24 {
25  return std::log(mu / (1 - mu));
26 }
27 
28 double mitk::LogItLinking::DLink(double mu)
29 {
30  return 1 / (mu * (1 - mu));
31 }
32 
34 {
35  double result;
36  if (eta < lowerBound)
37  {
38  result = 1 / (1 + std::exp(-lowerBound));
39  }
40  else if (eta > upperBound)
41  {
42  result = 1 / (1 + std::exp(-upperBound));
43  }
44  else
45  {
46  result = (1 / (1 + std::exp(-eta)));
47  }
48  if (result <0 ) result = 0;
49  if (result > 1) result = 1;
50 
51  return result;
52 }
double InverseLink(double eta) override
double Link(double mu) override
double DLink(double mu) override