Example #1
0
        static void TopMain(string [] args)
        {
            var source = Demos.MixtureSource;

            source.N        = 1000;
            source.Pk       = new [] { 0.35, 0.65 };
            source.Mean     = new [] { 7.0, 0.0 };
            source.Variance = new [] { 2.0, 8.0 };

            var data = source.Generate();

            var wm = new MultimodalWrappedApproximation {
                period              = 24,
                observedData        = data,
                approximation_count = 3,
                mixture_count       = 2,

                algorithm          = new GibbsSampling(),
                NumberOfIterations = 2500
            };

            wm.Infer("test.json");

            Console.WriteLine(source);
        }
Example #2
0
        public static void PeriodicSingle3()
        {
            var data = SingleSource.Generate();

            var wm = new MultimodalWrappedApproximation {
                observedData        = data,
                approximation_count = 1,
                mixture_count       = 2,
                period = period
            };

            wm.Infer();
            Console.WriteLine("{0}\n", SingleSource);

            Console.WriteLine("By approximating the wrapping as a mixture model (where we allow the model to place one component after and another before midnight), \nwe get better estimates, but the moments are still off because the wrapping wasn't accounted for." + "\n\n\n\n\n");
        }
Example #3
0
        public static void PeriodicSingle2()
        {
            var data = SingleSource.Generate();

            var wm = new MultimodalWrappedApproximation {
                observedData        = data,
                approximation_count = 3,
                mixture_count       = 1,
                period = period
            };

            wm.Infer();
            Console.WriteLine("{0}\n", SingleSource);

            Console.WriteLine("By introducing the wrapped approximation, both moments are better estimated." + "\n\n\n\n\n");
        }
Example #4
0
        public static void PeriodicSingle1()
        {
            var data = SingleSource.Generate();

            var wm = new MultimodalWrappedApproximation {
                observedData        = data,
                approximation_count = 1,
                mixture_count       = 1,
                period = period
            };

            wm.Infer();
            Console.WriteLine("{0}\n", SingleSource);

            Console.WriteLine("With a single-component GMM, the moments are badly estimated. (if the mean was not near midnight, the approximation might be sufficient)" + "\n\n\n\n\n");
        }
Example #5
0
        public static void PeriodicMixture2()
        {
            var data = MixtureSource.Generate();

            var wm = new MultimodalWrappedApproximation {
                observedData        = data,
                approximation_count = 3,
                mixture_count       = 2,
                period = period
            };

            wm.Infer();
            Console.WriteLine("{0}\n", MixtureSource);

            Console.WriteLine("Acounting for the wrapped nature in this mixture model seems to give more optimal results." + "\n\n\n\n\n");
        }
Example #6
0
        public static void PeriodicMixture1()
        {
            var data = MixtureSource.Generate();

            var wm = new MultimodalWrappedApproximation {
                observedData        = data,
                approximation_count = 1,
                mixture_count       = 2,
                period = period
            };

            wm.Infer();
            Console.WriteLine("{0}\n", MixtureSource);

            Console.WriteLine("The training data here are samplled from a mixture model. If we learn a non-wrapped mixture,the moments are poorly approximated.." + "\n\n\n\n\n");
        }
Example #7
0
        static void Main(string [] args)
        {
            var data = JsonConvert.DeserializeObject <double[]>(
                System.IO.File.ReadAllText(DataPath + "wash_lunch_dishes.json")
                );

            Console.WriteLine("{0} datapoints...", data.Count());

            var wm = new MultimodalWrappedApproximation {
                period              = 24,
                observedData        = data,
                approximation_count = 3,
                mixture_count       = 2,

                algorithm          = new ExpectationPropagation(),
                NumberOfIterations = 50
            };

            wm.Infer("hh101.json");
        }
Example #8
0
        public static void PeriodicSingle4()
        {
            var source = new PeriodicData {
                N        = N,
                Mean     = new [] { 5.0 },
                Variance = new [] { Math.Pow(8, 2) },
                Pk       = new [] { 1.0 },
                Period   = period
            };

            var data = source.Generate();

            var wm = new MultimodalWrappedApproximation {
                observedData        = data,
                approximation_count = 3,
                mixture_count       = 1,
                period = period
            };

            wm.Infer();
            Console.WriteLine("{0}\n", source);

            Console.WriteLine("Test it with large variance." + "\n\n\n\n\n");
        }