locked
How dos the compiler see a Dirichlet? RRS feed

  • Question

  • public class Class1
    {
    	public Class1()
    	{
    	}
        class program
        {
            static void Main()
            {
    
                Vector[] pros = new Vector[] { Vector.FromArray(0.3, 0.3,0.4 ) /* */, Vector.FromArray(0.3,0.3,0.4 ) /* */, 
                        Vector.FromArray(0.1, 0.4,0.5 ),Vector.FromArray(0.1,0.5,0.4 )};
                var Pros = pros.Select(v => Dirichlet.PointMass(v)).ToArray();
    
                VariableArray<Dirichlet> contributionPrior;
                VariableArray<Vector> contributionMatrix;
                Range K = new Range(4);
                Range D = new Range(3);
                Variable<PositiveDefiniteMatrix> MatrixC ;
                MatrixC = PositiveDefiniteMatrix.Identity(3);
                //MatrixC = Variable.WishartFromShapeAndScale(100.0, PositiveDefiniteMatrix.IdentityScaledBy(3, 0.01));
                
                contributionPrior = Variable.Array<Dirichlet>(K).Named("contributionprior");
    
               contributionMatrix = Variable.Array<Vector>(K).Named("Emission");
                contributionMatrix[K] = Variable<Vector>.Random<Dirichlet>(contributionPrior[K]);
                contributionMatrix.SetValueRange(D);
    
             
                Variable<Vector> r = Variable.VectorGaussianFromMeanAndPrecision(contributionMatrix[0], MatrixC);
    
               contributionPrior.ObservedValue = Pros;
                InferenceEngine ei = new InferenceEngine(new VariationalMessagePassing());
                ei.ShowFactorGraph = true;
    
                Console.WriteLine(ei.Infer(r));
                
                Console.Read();
    
            } 
        }
    
    }

    It complained that "Dirichlet is not of type Vector for argument 1 of method VectorGaussianOp.SampleAverageLogarithm(Vector Mean = Dirichlet, PositiveDefiniteMatrix Precision = PositiveDefiniteMatrix, VectorGaussian result = VectorGaussian)
    [1] ".

    I am confused, because I am using Variable<vector> as the first argument for 

    VectorGaussianFromMeanAndPrecision

    Monday, July 2, 2012 12:09 PM

Answers

  • At the moment, the mean of a VectorGaussian cannot have a Dirichlet prior.  Use a VectorGaussian prior instead.
    • Marked as answer by invisible911 Tuesday, July 10, 2012 11:11 AM
    Tuesday, July 3, 2012 11:58 AM
    Owner

All replies

  • You have defined contributionMatrix as Random<Dirichlet>.  The mean of a VectorGaussian should have a VectorGaussian distribution, not a Dirichlet distribution.
    Monday, July 2, 2012 4:09 PM
    Owner
  • Hi, Minka

    Thanks for your replay,

    I am trying to say that the mean of the VectorGaussian(i.e. each ContributionMatrix[k]) has a Dirichlet Prior. should not be expressed in this way?

    Liu 

    Monday, July 2, 2012 9:18 PM
  • At the moment, the mean of a VectorGaussian cannot have a Dirichlet prior.  Use a VectorGaussian prior instead.
    • Marked as answer by invisible911 Tuesday, July 10, 2012 11:11 AM
    Tuesday, July 3, 2012 11:58 AM
    Owner