problem with Variable.Array<VectorGaussian> (Migrated from community.research.microsoft.com) RRS feed

  • Question

  • julia posted on 07-29-2009 4:06 PM


    I am struggling with these four lines of code, I don't understand why I am getting an error.


    VariableArray<VectorGaussian> D = Variable.Array<VectorGaussian>(classRange);
    D[classRange] = Variable.New<VectorGaussian>().ForEach(classRange);

    VariableArray<Vector> x = Variable.Array<Vector>(classRange).Named("x");
    x[classRange] = Variable.Random<Vector, VectorGaussian>(D[classRange]);

    gives me an error at the execution of line 2:
         Unhandled Exception: System.InvalidOperationException: vVectorGaussian[ ]1[classRange] was not defined in this condition block.


    I'm guessing the problem comes from the fact that D is not properly initialized... but how can I define it other than what I have done?

    Is there another way to store an array of distributions? My intention was to update the "observed value" of the distribution array D with the results of the inference, using
         D.ObservedValue = Distribution.ToArray<VectorGaussian[ ]>( (IDistribution<Vector[ ]>) inferred[0])

    If I store D as an array of VectorGaussian instead of a VariableArray, then I am in trouble for the indexing, as x must be indexed by a range and D by an integer...

    Any help welcome! Many thanks,


    Friday, June 3, 2011 5:17 PM


  • minka replied on 08-12-2009 11:56 AM

    You don't want the second line at all.  The first line already creates an array with undefined elements.

    Friday, June 3, 2011 5:17 PM