# NDK_MD

 int __stdcall NDK_MD ( double * pData, size_t nSize, WORD reserved, double * retVal )

Returns the mean difference of the input data series.

Returns
status code of the operation
Return values
 NDK_SUCCESS Operation successful NDK_FAILED Operation unsuccessful. See Macros for full list.
Parameters
 [in] pData is the input data series (one/two dimensional array). [in] nSize is the number of observations in pData. [in] reserved This parameter is reserved and must be 1. [out] retVal is the computed value.
Remarks
1. The time series may include missing values (NaN), but they will not be included in the calculations.
2. The sample mean difference (MD) is computed as follows:
$\Delta = \mathrm{MD} = \frac{\sum_{i=1}^n \sum_{j=1}^n \| x_i - x_j \|}{n \times \left ( n-1 \right )}$
Where:
• $$x_i$$ is the value of the i-th non-missing observation.
• $$n$$ is the number of non-missing observations in the sample.
4. The mean difference is the product of the sample mean and the relative mean difference (RMD) and so can also be expressed in terms of the NDK_GINI:
$\mathrm{MD}= 2 \times G \times \bar{x}$
Where:
• $$\bar{x}$$ is the arithmetic sample mean.
• $$G$$ is the NDK_GINI.
6. Because of its ties to the Gini coefficient, the mean difference is also called the "Gini mean difference." It is also known as the "absolute mean difference."
7. The sample mean difference is not dependent on a specific measure of central tendency like the standard deviation.
8. The mean difference of a sample is an unbiased and consistent estimator of the population mean difference.
Requirements
Examples



 Namespace: NumXLAPI Class: SFSDK Scope: Public Lifetime: Static
 int NDK_MD ( double[] pData, UIntPtr nSize, short argMenthod, ref double retVal )

Returns the mean difference of the input data series.

Return Value

a value from NDK_RETCODE enumeration for the status of the call.

 NDK_SUCCESS operation successful Error Error Code
Parameters
 [in] pData is the input data series (one/two dimensional array). [in] nSize is the number of observations in pData. [in] argMenthod This parameter is reserved and must be 1. [out] retVal is the computed value.
Remarks
1. The time series may include missing values (NaN), but they will not be included in the calculations.
2. The sample mean difference (MD) is computed as follows:
$\Delta = \mathrm{MD} = \frac{\sum_{i=1}^n \sum_{j=1}^n \| x_i - x_j \|}{n \times \left ( n-1 \right )}$
Where:
• $$x_i$$ is the value of the i-th non-missing observation.
• $$n$$ is the number of non-missing observations in the sample.
4. The mean difference is the product of the sample mean and the relative mean difference (RMD) and so can also be expressed in terms of the NDK_GINI:
$\mathrm{MD}= 2 \times G \times \bar{x}$
Where:
• $$\bar{x}$$ is the arithmetic sample mean.
• $$G$$ is the NDK_GINI.
6. Because of its ties to the Gini coefficient, the mean difference is also called the "Gini mean difference." It is also known as the "absolute mean difference."
7. The sample mean difference is not dependent on a specific measure of central tendency like the standard deviation.
8. The mean difference of a sample is an unbiased and consistent estimator of the population mean difference.
Exceptions
Exception Type Condition
None N/A
Requirements
Namespace NumXLAPI SFSDK Public Static NumXLAPI.DLL
Examples

References
Hull, John C.; Options, Futures and Other DerivativesFinancial Times/ Prentice Hall (2011), ISBN 978-0132777421