locked
Two streams of observations, one common influencing factor RRS feed

  • Question

  • Hi,

    I have two variables, each with a continuous streams of observations.

    Both variables are influence by one shared (gaussian) influence and one that is different for both (also gaussian), as well as a noice factor(gamma).

    Is it possible to find the shared gaussian distribution?

    (For Example: I have Variable A(gaussian) and B(gaussian), Both are influence by X(gaussian), N(gamma), Only A is influence by S(gaussian) and only B is influence by T(gaussian)

    Thanks for reading,

    Xardas


    Is it possible to do something like:

           

    Variable<double> averageExpansionX = Variable.GaussianFromMeanAndPrecision(0, 0.01);

    Variable<double> averageExpansionS = Variable.GaussianFromMeanAndPrecision(0, 0.01);

    Variable<double> averageExpansionT = Variable.GaussianFromMeanAndPrecision(0, 0.01);

    Variable<double> precisionY = Variable.GammaFromShapeAndScale(2.0, 0.5);           

    Variable<double> nextPointA = Variable.GaussianFromMeanAndPrecision(0.5 * averageExpansionX + 0.5 * averageExpansionS, precisionN);

    Variable<double> nextPointB = Variable.GaussianFromMeanAndPrecision(0.5 * averageExpansionX + 0.5 * averageExpansionT, precisionN);






    • Edited by XardasM Monday, May 7, 2012 2:01 PM
    Monday, May 7, 2012 12:57 PM

Answers

  • I'm not sure exactly what you are asking here. This is a valid model. If you have multiple points, it looks as follows which runs and gives sensible answers:

       Variable<double> averageExpansionX = Variable.GaussianFromMeanAndPrecision(0, 0.01); 
       Variable<double> averageExpansionS = Variable.GaussianFromMeanAndPrecision(0, 0.01); 
       Variable<double> averageExpansionT = Variable.GaussianFromMeanAndPrecision(0, 0.01); 
       Variable<double> precisionY = Variable.GammaFromShapeAndScale(2.0, 0.5);  
     
       Variable<int> numPoints =Variable.New<int>(); 
       Range N = new Range(numPoints); 
       VariableArray<double> pointA = Variable.Array<double>(N); 
       VariableArray<double> pointB = Variable.Array<double>(N); 
       pointA[N] = Variable.GaussianFromMeanAndPrecision(0.5 * averageExpansionX + 0.5 * averageExpansionS, precisionY).ForEach(N); 
       pointB[N] = Variable.GaussianFromMeanAndPrecision(0.5 * averageExpansionX + 0.5 * averageExpansionT, precisionY).ForEach(N); 
     
       double[] dataA = new double[] { 1, 2, 1, 1, 2, 1.5 }; 
       double[] dataB = new double[] { 2, 3, 2.5, 2, 2.5, 1.5 }; 
     
       numPoints.ObservedValue = dataA.Length; 
       pointA.ObservedValue = dataA; 
       pointB.ObservedValue = dataB; 
     
       var engine = new InferenceEngine(); 
     
       Console.WriteLine(engine.Infer(averageExpansionX)); 
       Console.WriteLine(engine.Infer(averageExpansionS)); 
       Console.WriteLine(engine.Infer(averageExpansionT)); 
       Console.WriteLine(engine.Infer(precisionY)); 


    Tuesday, May 8, 2012 2:40 PM
    Owner

All replies

  • I'm not sure exactly what you are asking here. This is a valid model. If you have multiple points, it looks as follows which runs and gives sensible answers:

       Variable<double> averageExpansionX = Variable.GaussianFromMeanAndPrecision(0, 0.01); 
       Variable<double> averageExpansionS = Variable.GaussianFromMeanAndPrecision(0, 0.01); 
       Variable<double> averageExpansionT = Variable.GaussianFromMeanAndPrecision(0, 0.01); 
       Variable<double> precisionY = Variable.GammaFromShapeAndScale(2.0, 0.5);  
     
       Variable<int> numPoints =Variable.New<int>(); 
       Range N = new Range(numPoints); 
       VariableArray<double> pointA = Variable.Array<double>(N); 
       VariableArray<double> pointB = Variable.Array<double>(N); 
       pointA[N] = Variable.GaussianFromMeanAndPrecision(0.5 * averageExpansionX + 0.5 * averageExpansionS, precisionY).ForEach(N); 
       pointB[N] = Variable.GaussianFromMeanAndPrecision(0.5 * averageExpansionX + 0.5 * averageExpansionT, precisionY).ForEach(N); 
     
       double[] dataA = new double[] { 1, 2, 1, 1, 2, 1.5 }; 
       double[] dataB = new double[] { 2, 3, 2.5, 2, 2.5, 1.5 }; 
     
       numPoints.ObservedValue = dataA.Length; 
       pointA.ObservedValue = dataA; 
       pointB.ObservedValue = dataB; 
     
       var engine = new InferenceEngine(); 
     
       Console.WriteLine(engine.Infer(averageExpansionX)); 
       Console.WriteLine(engine.Infer(averageExpansionS)); 
       Console.WriteLine(engine.Infer(averageExpansionT)); 
       Console.WriteLine(engine.Infer(precisionY)); 


    Tuesday, May 8, 2012 2:40 PM
    Owner
  • Thanks, I just wasn't sure whether it was possible to do it like this and still get sensible answers for

    engine.Infer(averageExpansionX); 
    engine.Infer(averageExpansionS); 
    engine.Infer(averageExpansionT); 

    Wednesday, May 9, 2012 8:52 AM
  • As a followup question:

    is it possible to use a random variable as mixing coefficient between those two instead of 0.5?

    I want to find out which factors of the two expansions at PointA and PointB are shared and which are different between those 2.

    For example:

    5 is added to each point with each observation.

    1 is substracted from point A with each observation.

    and 1 is added to point B with each observation.

    Is it possible to find out about these influences?

    (Of course there would be many different solutions, the one chosen should be one that minimizes the distribution that is not shared)

    TL;DR (In short):

    Is there a way to force the inference engine to minimize one distribution if multiple distributions are used do describe one random variable? (Like in this example)

    pointA[N] = Variable.GaussianFromMeanAndPrecision(0.5 * averageExpansionX + 0.5 * averageExpansionS, precisionY).ForEach(N); 



    • Edited by XardasM Tuesday, June 19, 2012 9:50 AM
    Monday, June 18, 2012 1:21 PM