Exemple #1
0
        public override bool IsValid()
        {
            if (!base.IsValid())
            {
                return(false);
            }
            if (_component.Count == 0)
            {
                return(false);
            }

            if (IsSignificantlyGreater(totalWeight(), 1.0))
            {
                return(false);
            }
            if (IsSignificantlySmaller(totalWeight(), 1.0))
            {
                return(false);
            }

            SingletonLogger.Instance().DebugLog(typeof(Mixture), "_component.Count: " + _component.Count);

            foreach (MixtureComponent mc in _component)
            {
                IDistribution d = mc.Distribution;
                double        w = mc.Weight;
                if (IsSignificantlySmaller(w, mc.MinWeight))
                {
                    throw new Exception("Incompatible mixture weight too small");
                }
                if (IsSignificantlyGreater(w, mc.MaxWeight))
                {
                    throw new Exception("Incompatible mixture weight too big");
                }

                SingletonLogger.Instance().DebugLog(typeof(Mixture), "dist: " + d + " w: " + w);
                SingletonLogger.Instance().DebugLog(typeof(Mixture), "contains: " + Contains(d));
                if (d.SampleSpace != this.SampleSpace)
                {
                    SingletonLogger.Instance().DebugLog(typeof(Mixture), "SS MISMATCH");
                    SingletonLogger.Instance().DebugLog(typeof(Mixture), "d.SS: " + d.SampleSpace + " hash=" + d.GetHashCode());
                    SingletonLogger.Instance().DebugLog(typeof(Mixture), "this.SS: " + this.SampleSpace + " hash=" + this.GetHashCode());
                    throw new Exception("Incompatible IDistribution in Mixture");
                }
            }


            return(true);
        }