[101065a] | 1 | /** |
---|
| 2 | This software was developed by the University of Tennessee as part of the |
---|
| 3 | Distributed Data Analysis of Neutron Scattering Experiments (DANSE) |
---|
| 4 | project funded by the US National Science Foundation. |
---|
| 5 | |
---|
| 6 | If you use DANSE applications to do scientific research that leads to |
---|
| 7 | publication, we ask that you acknowledge the use of the software with the |
---|
| 8 | following sentence: |
---|
| 9 | |
---|
| 10 | "This work benefited from DANSE software developed under NSF award DMR-0520547." |
---|
| 11 | |
---|
| 12 | copyright 2008, University of Tennessee |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | #include <math.h> |
---|
| 16 | #include "parameters.hh" |
---|
| 17 | #include <stdio.h> |
---|
| 18 | using namespace std; |
---|
| 19 | #include "logNormal.h" |
---|
| 20 | |
---|
| 21 | LogNormal :: LogNormal() { |
---|
| 22 | scale = Parameter(1.0, true); |
---|
| 23 | sigma = Parameter(1.0, true); |
---|
| 24 | center = Parameter(0.0, true); |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | /** |
---|
| 28 | * Function to evaluate 1D Log normal function. |
---|
| 29 | * The function is normalized to the 'scale' parameter. |
---|
| 30 | * |
---|
| 31 | * f(x)=scale * 1/(sigma*math.sqrt(2pi))e^(-1/2*((math.log(x)-mu)/sigma)^2) |
---|
| 32 | * |
---|
| 33 | * @param q: q-value |
---|
| 34 | * @return: function value |
---|
| 35 | */ |
---|
| 36 | double LogNormal :: operator()(double q) { |
---|
| 37 | double sigma2 = pow(sigma(), 2); |
---|
| 38 | return scale() / (q*sigma2) * exp( -pow((log(q) - center()), 2) / (2*sigma2)); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | /** |
---|
| 42 | * Function to evaluate 2D LogNormal function |
---|
| 43 | * The function is normalized to the 'scale' parameter. |
---|
| 44 | * |
---|
| 45 | * f(x,y) = LogNormal(x) * LogNormal(y) |
---|
| 46 | * |
---|
| 47 | * where both LogNormals share the same parameters. |
---|
| 48 | * @param q_x: value of Q along x |
---|
| 49 | * @param q_y: value of Q along y |
---|
| 50 | * @return: function value |
---|
| 51 | */ |
---|
| 52 | double LogNormal :: operator()(double qx, double qy) { |
---|
| 53 | return (*this).operator()(qx) * (*this).operator()(qy); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | /** |
---|
| 57 | * Function to evaluate 2D LogNormal function |
---|
| 58 | * The function is normalized to the 'scale' parameter. |
---|
| 59 | * |
---|
| 60 | * f(x,y) = LogNormal(x) * LogNormal(y) |
---|
| 61 | * |
---|
| 62 | * where both LogNormals share the same parameters. |
---|
| 63 | * @param q: q-value |
---|
| 64 | * @param phi: angle phi |
---|
| 65 | * @return: function value |
---|
| 66 | */ |
---|
| 67 | double LogNormal :: evaluate_rphi(double q, double phi) { |
---|
| 68 | double qx = q*cos(phi); |
---|
| 69 | double qy = q*sin(phi); |
---|
| 70 | return (*this).operator()(qx, qy); |
---|
| 71 | } |
---|
| 72 | /** |
---|
| 73 | * Function to calculate effective radius |
---|
| 74 | * @return: effective radius value |
---|
| 75 | */ |
---|
| 76 | double LogNormal :: calculate_ER() { |
---|
| 77 | //NOT implemented yet!!! |
---|
| 78 | return 0.0; |
---|
| 79 | } |
---|