Exemple #1
0
        /// <summary>
        /// Takes a probability (in [0,1]) and returns corresponding z (standard normal) value
        /// </summary>
        /// <param name="prob">in [0,1]</param>
        /// <returns></returns>
        public static double FindZ(double prob)
        {
            double returnZ;
            int    returnZIndex;
            double lookUp = Math.Max(Math.Min(prob, 1.0), 0.0);

            lookUp = ZTransformer.ZTransformGivenZ(lookUp);
            Boolean lowerHalf = false;

            if (lookUp < .5)
            {
                lookUp    = 1 - lookUp;
                lowerHalf = true;
            }
            returnZIndex = invZTable.Count - 1;
            for (int i = 0; i < invZTable.Count - 1; i++)
            {
                if (lookUp <= invZTable[i].probability)
                {
                    returnZIndex = i;
                    break;
                }
            }
            returnZ = invZTable[returnZIndex].zValue;
            if (lowerHalf)
            {
                returnZ = -returnZ;
            }
            return(returnZ);
        }
Exemple #2
0
        private static void ObfuscateDoubleValue(ref DetectedAttributeValue targetDV, ref Random random)
        {
            double confidence = targetDV.stdDev;
            double dblVal     = ((DoubleValue)((DetectedAttributeValue)targetDV).value).value;
            double X          = random.NextDouble();
            double Y          = .5 - (X / 2);
            double Z          = ZTransformer.ZTransformGivenProbability(Y);

            //double area = (double)(random.Next((int)(Z * 10), (int)(Z * -10)) / 10.0);


            //obfuscate int
            ((DoubleValue)((DetectedAttributeValue)targetDV).value).value = (double)(Z * confidence + dblVal);
            //exit
            targetDV.stdDev = GetConfidence(Y) * 100;
        }
Exemple #3
0
        private static void ObfuscateLocationValue(ref DetectedAttributeValue targetDV, ref Random random)
        {
            double confidence = targetDV.stdDev;
            double x          = ((LocationValue)((DetectedAttributeValue)targetDV).value).X;
            double y          = ((LocationValue)((DetectedAttributeValue)targetDV).value).Y;
            double z          = ((LocationValue)((DetectedAttributeValue)targetDV).value).Z;
            double X          = random.NextDouble();
            double Y          = .5 - (X / 2);
            double Z          = ZTransformer.ZTransformGivenProbability(Y);

            //obfuscate X
            ((LocationValue)((DetectedAttributeValue)targetDV).value).X = (double)(Z * confidence + x);
            //obfuscate Y
            ((LocationValue)((DetectedAttributeValue)targetDV).value).Y = (double)(Z * confidence + y);
            //obfuscate Z
            ((LocationValue)((DetectedAttributeValue)targetDV).value).Z = (double)(Z * confidence + z);
            //exit
            targetDV.stdDev = GetConfidence(Y) * 100;
        }
Exemple #4
0
        private static void ObfuscateVelocityValue(ref DetectedAttributeValue targetDV, ref Random random)
        {
            double confidence = targetDV.stdDev;
            double vx         = ((VelocityValue)((DetectedAttributeValue)targetDV).value).VX;
            double vy         = ((VelocityValue)((DetectedAttributeValue)targetDV).value).VY;
            double vz         = ((VelocityValue)((DetectedAttributeValue)targetDV).value).VZ;
            double X          = random.NextDouble();
            double Y          = .5 - (X / 2);
            double Z          = ZTransformer.ZTransformGivenProbability(Y);

            //double area = (double)(random.Next((int)(Z * 10), (int)(Z * -10)) / 10.0);

            //obfuscate VX
            ((VelocityValue)((DetectedAttributeValue)targetDV).value).VX = (double)(Z * confidence + vx);
            //obfuscate VY
            ((VelocityValue)((DetectedAttributeValue)targetDV).value).VY = (double)(Z * confidence + vy);
            //obfuscate VZ
            ((VelocityValue)((DetectedAttributeValue)targetDV).value).VZ = (double)(Z * confidence + vz);
            //exit
            targetDV.stdDev = GetConfidence(Y) * 100;
        }
Exemple #5
0
        private static void ObfuscateStringValue(ref DetectedAttributeValue targetDV, ref Random random)
        {
            double confidence = targetDV.stdDev;
            string strVal     = ((StringValue)((DetectedAttributeValue)targetDV).value).value;
            double X          = random.NextDouble();
            double Y          = .5 - (X / 2);
            double Z          = ZTransformer.ZTransformGivenProbability(Y);
            int    strLen     = strVal.Length;

            strLen = (int)Math.Round((Z * confidence) + strLen, 0);
            char[] str;
            if (strLen <= strVal.Length)
            {
                str = strVal.ToCharArray(0, strLen);
            }
            else
            {
                for (int b = strVal.Length; b < strLen; b++)
                {
                    strVal += Convert.ToChar(random.Next(49, 122));
                }
                str = strVal.ToCharArray();
            }
            StringBuilder sb = new StringBuilder();

            for (int a = 0; a < strLen; a++)
            {
                int asciiVal = Convert.ToInt32(str[a]);
                asciiVal = (int)Math.Round((ZTransformer.ZTransformGivenProbability(.5 - (random.NextDouble() / 2)) * confidence) + asciiVal, 0);
                //str[a] = Convert.ToChar(asciiVal);
                sb.Append(Convert.ToChar(asciiVal));
            }
            //((StringValue)((DetectedAttributeValue)targetDV).attribute).value = str.ToString();
            ((StringValue)((DetectedAttributeValue)targetDV).value).value = sb.ToString();
            targetDV.stdDev = GetConfidence(Y) * 100;
        }