Files
bigdata-coursera/hw6cs/Program.cs
T

68 lines
1.6 KiB
C#

using System.Collections.Generic;
using System.Linq;
namespace hw6cs
{
public class Condition
{
public char Name { get; private set; }
public bool IsTrue { get; private set; }
public Condition(char name, bool tf)
{
Name = name;
IsTrue = tf;
}
public Condition Clone() { return new Condition(Name, IsTrue); }
public Condition Negate() { return new Condition(Name, !IsTrue); }
public bool Equals(Condition other)
{
return Name == other.Name && IsTrue == other.IsTrue;
}
}
public class Variable
{
public double Probability { get; private set; }
public IEnumerable<Condition> Conditions { get; private set; }
public Variable(IEnumerable<Condition> conditions, double probability)
{
Probability = probability;
Conditions = conditions;
}
public Variable Negate()
{
return new Variable(
Conditions.Take(1).Select(c => c.Negate())
.Concat(Conditions.Skip(1)), 1.0 - Probability);
}
//public bool Join(Variable other, char condition)
//{
//}
}
class Program
{
static void Main(string[] args)
{
//var pa = new List<Variable> { new Variable(new[] { new Condition('a', true) }, .01) };
//var pta = new List<Variable> {
// new Variable(new[] { new Condition('t', true), new Condition('a', true) }, .05),
// new Variable(new[] { new Condition('t', true), new Condition('a', false) }, .01) };
//var ps = new List<Variable> { new Variable(new[] { new Condition('s', true) }, .50) };
//from ac in pa
//join tac in pta on ac.Join(tac, 'a') into ha
}
}
public
}