Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

MS 2015 Statistics.Median generates error -20104

 

MS v15.0.0.49153 generates unknown exception error -20104 when NaN is found in array. Statistics.Mean handles this condition by returning NaN and not generating an exception. Following code demonstrates:

 

      Random rnd = new Random();
      double[] tmp = new double[10];
      for (int j=0; j < tmp.Length; j++) tmp[j] = rnd.Next ();
      Console.WriteLine (Statistics.Mean (tmp));
      Console.WriteLine (Statistics.Median (tmp));
      tmp[5] = Double.NaN;
      Console.WriteLine (Statistics.Mean (tmp));
      Console.WriteLine (Statistics.Median (tmp));

 

Last statement causes unknown exception error. Would prefer to either return NaN or generate a known error.

 

0 Kudos
Message 1 of 2
(3,569 Views)

When I enter in error code -20104 into LabVIEW's "Explain Error" tool I recieve the following message:

 

Possible reason(s):

Analysis: Input parameters have at least one NaN element.

 

I believe this is the type of behavior you were looking for, though it might not necessarily be shown in MS 2015.

0 Kudos
Message 2 of 2
(3,560 Views)