コード例 #1
0
        public static BaseDistribution DistributionUnary(BaseDistribution value, NodeOperationType operationType)
        {
            if (value.InnerDistributionType == DistributionType.Number)
            {
                return(EvaluateDoubleUnary((double)value, operationType));
            }
            else
            {
                switch (operationType)
                {
                case NodeOperationType.Abs:
                {
                    return(value.InnerGetAbs());
                }

                case NodeOperationType.Negate:
                {
                    return(value.InnerGetNegate());
                }

                case NodeOperationType.Sqrt:
                {
                    return(value.InnerGetPower(0.5));
                }

                case NodeOperationType.Ln:
                {
                    return(value.InnerGetLog(Math.E));
                }

                case NodeOperationType.Lg10:
                {
                    return(value.InnerGetLog(10));
                }

                case NodeOperationType.Sin:
                {
                    return(CommonRandomMath.Sin(value));
                }

                case NodeOperationType.Cos:
                {
                    return(CommonRandomMath.Cos(value));
                }

                case NodeOperationType.Tan:
                {
                    return(CommonRandomMath.Tan(value));
                }

                default:
                {
                    throw new NotImplementedException();
                }
                }
            }
        }
コード例 #2
0
        public static BaseDistribution DistributionBinary(BaseDistribution left, BaseDistribution right, NodeOperationType operationType)
        {
            if (left.InnerDistributionType == DistributionType.Number && right.InnerDistributionType == DistributionType.Number)
            {
                return(EvaluateDoubleBinary((double)left, (double)right, operationType));
            }
            else
            {
                switch (operationType)
                {
                case NodeOperationType.Sum:
                {
                    return(left + right);
                }

                case NodeOperationType.Substract:
                {
                    return(left - right);
                }

                case NodeOperationType.Multiply:
                {
                    return(left * right);
                }

                case NodeOperationType.Divide:
                {
                    return(left / right);
                }

                case NodeOperationType.Power:
                {
                    return(left.InnerGetPower(right));
                }

                case NodeOperationType.Log:
                {
                    return(left.InnerGetLog(right));
                }

                default:
                {
                    throw new NotImplementedException();
                }
                }
            }
        }