I don't know how to convert the data with type <int> to type <double> T _ T RRS feed

All replies

  • Use Variable.Double()


    Thursday, January 14, 2016 10:33 AM
  • Thank you for answering !

    But I have one more problem.  Actually I have to convert 'int array' data to 'double array'.

    Variable.Double()  takes  only <int> not <int[]>. please help me T T

    Friday, January 15, 2016 5:26 AM
  • Hmm, not sure if we have an overload for this. Tom?

    If not, you can easily write your own:

            public static double[] ToDouble(int[] array)
                return array.Select(x => (double)x).ToArray();

    Then you can invoke it this way:

            var intArray = Variable.Observed(new[] { 1, 2, 3 });
            var doubleArray = Variable<double[]>.Factor(ToDouble, intArray);
            var sum = Variable.Sum(doubleArray);


    Friday, January 15, 2016 2:11 PM
  • It would help to have more context for this question.  Are you trying to convert the data in C# or as part of the Infer.NET model? 
    Tuesday, February 2, 2016 1:28 PM