コード例 #1
0
        private void CalcF2ProbabilitiesGxyNew()
        {
            if (null != _probCalcF1)
            {
                return;
            }
            int resultsCount = 1 << _f2.OutputNumberOfDigits;

            Gprobabilites[] boolFunc2Gp     = new Gprobabilites[resultsCount];
            double[]        f2ProbalityZero = new double[_f2.InputNumberOfDigits];

            for (int i = 0; i < f2ProbalityZero.Length; i++)
            {
                f2ProbalityZero[i] = _inputDistortionProb.ZeroProbability[i + _f1.InputNumberOfDigits - _f2.OutputNumberOfDigits];
            }

            var f2Calc = new ProbabilitiesGxyCalc(_f2, f2ProbalityZero);

            double[] probabilityZeroF1 = new double[_f1.InputNumberOfDigits];
            // copy input zero probability for function f1 in range [1,..,t]
            for (int i = 0; i < _f1.InputNumberOfDigits - _f2.OutputNumberOfDigits; i++)
            {
                probabilityZeroF1[i] = _inputDistortionProb.ZeroProbability[i];
            }
            for (int i = 0; i < _f2.OutputNumberOfDigits; i++)
            {
                probabilityZeroF1[i + _f1.InputNumberOfDigits - _f2.OutputNumberOfDigits] = 0.0;
            }
            // create Gprobabilities for a separate bit of f2 function result
            const int BinaryDigitState = 2;

            Gprobabilites[][] digitSeparateProb = new Gprobabilites[BinaryDigitState][];
            for (int i = 0; i < BinaryDigitState; i++)
            {
                digitSeparateProb[i] = new Gprobabilites[f2Calc.OutputNumberOfDigits()];
            }
            // calc results probabilities
            int      indexBoolFunc2Gp = 0;
            BitArray resultVect       = new BitArray(_f2.OutputNumberOfDigits, false); // 00...0

            do
            {
                boolFunc2Gp[indexBoolFunc2Gp] = f2Calc.GetGprobabilitesResult(resultVect);
                // calc G prob of separate bits of result
                for (int i = 0; i < digitSeparateProb[0].Length; i++)
                {
                    int digit = resultVect[i] ? 1 : 0;
                    digitSeparateProb[digit][i].G0   = boolFunc2Gp[indexBoolFunc2Gp].G0;
                    digitSeparateProb[digit][i].Gc  += boolFunc2Gp[indexBoolFunc2Gp].Gc;
                    digitSeparateProb[digit][i].Gce += boolFunc2Gp[indexBoolFunc2Gp].Gce;
                    digitSeparateProb[digit][i].Gee += boolFunc2Gp[indexBoolFunc2Gp].Gee;
                }
                ++indexBoolFunc2Gp;
            } while (BooleanFuntionWithInputDistortion.IncrementOperand(resultVect));
            var prodClasses = new ProductClasses(_inputDistortionProb, digitSeparateProb, _f1.InputNumberOfDigits);

            _probCalcF1 = new ProbabilitiesGxyCalc(_f1, prodClasses);
        }
コード例 #2
0
        private ProductClasses _inputBitsDistortionsProbabilities; // contain probabilites g0, gcaij, geaij, p0i, p1i
        // next data stored in _truthTable
        //private double[] _distortionToZeroProbability; //g const0
        //private double[] _distortionToOneProbability; // g const1
        //private double[] _distortionToInverseProbability; // g inv

        // store for intermediate calculation
        // first [] correspond to 0 or 1 value of binary digit in tuple
        //private double[] _correctValueProbability; // gxaij -> the same as _correctValueProbability in truth Table
        //private double[][] _autoCorrectionValueProbability; // gcaij
        //private double[][] _distortedValueProbability; // geaij

        public ProbabilitiesGxyCalc(BooleanFuntionWithInputDistortion truthTable, double[] probalityZero)
        {
            _truthTable = truthTable;
            // TODO: move probalityZero to truthTable class (AbstractBooleanFuntionWithInputDistortion)
            if (probalityZero.Length != truthTable.InputNumberOfDigits)
            {
                throw new Exception("Length of probalityZero array don't fit the InputNumberOfDigits of truth table");
            }
            // const int BinaryDigitStates = 2;
            // _probalityZeroAndOne = new double[BinaryDigitStates][];
            // _probalityZeroAndOne[0] = new double[_truthTable.InputNumberOfDigits];
            // _probalityZeroAndOne[1] = new double[_truthTable.InputNumberOfDigits];
            //  for (int i = 0; i < probalityZero.Length; i++)
            // {
            //     _probalityZeroAndOne[0][i] = probalityZero[i];
            //     _probalityZeroAndOne[1][i] = 1 - probalityZero[i];
            // }
            _inputBitsDistortionsProbabilities = new ProductClasses(probalityZero, truthTable);
        }
コード例 #3
0
 public ProbabilitiesGxyCalc(BooleanFuntionWithInputDistortion truthTable, ProductClasses prodClasses)
 {
     _truthTable = truthTable;
     _inputBitsDistortionsProbabilities = prodClasses;
 }