Ejemplo n.º 1
0
		public void Gaussian_Membership()
		{
			Subset a = new Gaussian(3.0, 2.0);
			Assert.AreEqual(1.0, a.membership(3.0), "Invalid mode point");
			Assert.AreEqual(Math.Exp(-0.5), a.membership(1.0), "Invalid left point");
			Assert.AreEqual(Math.Exp(-2), a.membership(7.0), "Invalid left point");
		}
Ejemplo n.º 2
0
		public GaussianClassifier(string[] names,
			                          double begin=0.0, double end=1.0,
			                          string name="", 
			                          bool edge=false, double cross=1.0)
		{
			this.Domain = new Domains.RationalRange(begin, end);
			double wide, step, p;
			if (names.Length<2) {
				throw new ArgumentException();
			}
			if (!edge) {
				wide = (end-begin)*cross / (2*(names.Length+1));
				step = (end-begin) / (names.Length + 1);
				p = begin + (end-begin) / (names.Length + 1);
			}
			else {
				wide = (end-begin)*cross / (names.Length*2 - 2);
				step = (end-begin) / (names.Length - 1);
				p = begin;
			}
//			Console.WriteLine("Gaussian classifier ctor");
//			Console.WriteLine("edge={0}, cross={1}, begin={2}, end={3}, n={4}", edge, cross, begin, end, names.Length);
//			Console.WriteLine("wide={0}, step={1}, p={2}", wide, step, p);
			foreach (string term in names) {
				this[term] = new Gaussian(p, wide/3.0);
				p+=step;
			}
		}
Ejemplo n.º 3
0
		public void Gaussian_Centroid()
		{
			Subset a = new Gaussian(3.0, 2.0);
			Assert.AreEqual(3.0, a.centroid(), "Invalid gaussian centriod");
		}
Ejemplo n.º 4
0
		public void Gaussian_Boundaries()
		{
			Subset a = new Gaussian(3.0, 2.0);
			Assert.AreEqual(-7.0, a.Domain.begin, "Invalid begin point");
			Assert.AreEqual(13.0, a.Domain.end, "Invalid end point");
		}