Esempio n. 1
0
        //public HyperGeometricProbability(int N=0, int n=0, int y=0, int r=0, NuGenProbability::RandomVariableType rvt=EQUAL);

        /// <summary>
        /// The HyperGeometric probability is defined by:
        /// The equation: (rCy)*((N-r)C(n-y))/(NCn)
        /// where (x C y ) represents a combination, "x choose y"
        /// </summary>
        /// <param name="N">the population size; N must be > 0</param>
        /// <param name="n">the sample size; must be n is less than or equal to N</param>
        /// <param name="y">the sample set of items we are interested in.</param>
        /// <param name="r">the number of items from the sample set we are interested in. must be y is less than or equal to r</param>
        /// <param name="rvt">type of the random variable</param>
        public NuGenHyperGeometricProbability(int N, int n, int y, int r, RandomVariableType rvt)
            : base(y, rvt)
        {
            m_population  = N;
            m_sample      = n;
            m_red         = y;
            m_black       = n - y;
            m_selectedset = r;

            if (!(y <= r))
            {
                throw new NuGenProbabilityException("y <= r");
            }
            if (!(n - y <= N - r))
            {
                throw new NuGenProbabilityException("n-y <= N-r");
            }
            if (!(y >= 0))
            {
                throw new NuGenProbabilityException("y>=0");
            }
            if (!(N > 0))
            {
                throw new NuGenProbabilityException("N>0");
            }
            if (!(r >= 0))
            {
                throw new NuGenProbabilityException("r>=0");
            }
            if (!(n >= 0))
            {
                throw new NuGenProbabilityException("n>=0");
            }
        }
		//public NuGenPoissonProbability(int Y=0,double Lambda=0,NuGenProbability::RandomVariableType rvt=EQUAL);

		/// <summary>
		///  The Poisson probability.
		/// The equation for this probability is:
		/// P(Y) = lambda^Y * e^lambda / Y!
		/// </summary>
		/// <param name="Y">The number of events we want to know the probability of happening given a known average in a given time period.</param>
		/// <param name="Lambda">The average number of events in a given time period.</param>
		/// <param name="rvt">The random variable type. Whether it is cumulative or not and which way.</param>
		public NuGenPoissonProbability(int Y, double Lambda, RandomVariableType rvt): base(Y,rvt)
		{
			m_changes=Y;
			m_poisson_average=Lambda;

			if(!(Y >=0)) throw new NuGenProbabilityException("Y >=0");
			if(!(Lambda >=0)) throw new NuGenProbabilityException("Lambda >=0");
		}
		//public GeometricProbability(int Y=0, double p=1.0, NuGenProbability::RandomVariableType rvt=EQUAL);

		/*	The discrete geometric probability
			The equation for this probability is:
			P(Y) = (1.0-p)^(y-1) * p
		*/

		/// <summary>
		/// Constructs a geometric probability
		/// </summary>
		/// <param name="Y">The number of the trial that the success occurs on. Must be 0 is less than or equal to Y</param>
		/// <param name="p">Chance of success for each trial.	Must be 0.0 is less than or equal to p which is less than or equal to 1.0</param>
		/// <param name="rvt">Random variable comparison. Whether this probability is cumulative and which way it is. </param>
		public NuGenGeometricProbability(int Y, double p, RandomVariableType rvt) : base(Y,rvt) 
		{
			m_trial_of_success=Y;
			m_chance_of_success=p;

			if(!(Y>=0)) throw new NuGenProbabilityException("Y>=0");
			if(!(p >= 0.0  && p<=1.0)) throw new NuGenProbabilityException("p >= 0.0  && p<=1.0");
		}
		/*  The discrete binomial probability.
			The equation for this probability is:
			P(Y) = N!/((N-Y)!Y!)*p^Y*(1-p)^(N-Y)
		*/

		#region Constructors

		/// <summary>
		/// Constructs a binomial probability
		/// </summary>
		/// <param name="N">number of trials of this experiment; must be 0 is less than or equal to N</param>
		/// <param name="Y">number of successful trials; must be 0 is less than or equal to Y which is less than or equal to N</param>
		/// <param name="p">chance of success for each trial; must be 0.0 is less than or equal to p which is less than or equal to 1.0</param>
		/// <param name="rvt">Random variable comparison. Whether this probability is cumulative and which way it is.</param>

		NuGenBinomialProbability(int N , int Y, double p, RandomVariableType rvt) : base(Y, rvt)
		{
			m_trials= N;
			m_successes=Y;
			m_chance_of_success=p;

			if (!(Y<=N && Y >=0)) throw new NuGenProbabilityException("Y<=N && Y >=0");
			if (!(p >=0.0 && p<=1.0)) throw new NuGenProbabilityException("p >=0.0 && p<=1.0");
		}
Esempio n. 5
0
 public RandomVariableWindow(RandomVariable randomVariable)
 {
     this.Type          = randomVariable.Type;
     this.Title         = randomVariable.Name;
     RandomVariableList = randomVariable.Argument;
     InitializeComponent();
     UpdateContents();
     this.CenterToParent();
 }
		//public NuGenNegativeBinomialProbability(int Y=1, int K=1, double p=0.0, NuGenProbability::RandomVariableType rvt=EQUAL);
		/// <summary>
		/// The Negative Binomial NuGenProbability
		/// The equation for this probability is:
		/// P(Y) = (Y-1)!/(((Y-1)-(K-1))!(K-1)!)*p^K*(1-p)^(Y-K)
		/// </summary>
		/// <param name="Y">number of the trial that the kth success happens; must be 0 less than or equal to Y</param>
		/// <param name="K">number of successful trials; must be 0 is less than or equal to K which is less than or equal to Y</param>
		/// <param name="p">chance of success for each trial; must be 0.0 is less than or equal to p which is less than or equal to 1.0</param>
		/// <param name="rvt">Random variable comparison. Whether this probability is cumulative and which way it is.</param>
		public NuGenNegativeBinomialProbability(int Y, int K, double p, RandomVariableType rvt) : base(Y,rvt)
		{
			m_trials=Y;
			m_kth_success=K;
			m_chance_of_success=p;

			if(!(0<=Y && K>=0)) throw new NuGenProbabilityException("0<=Y && K>=0");
			if(!(p >=0.0 && p<=1.0)) throw new NuGenProbabilityException("p >=0.0 && p<=1.0");
		}
        //public NuGenPoissonProbability(int Y=0,double Lambda=0,NuGenProbability::RandomVariableType rvt=EQUAL);

        /// <summary>
        ///  The Poisson probability.
        /// The equation for this probability is:
        /// P(Y) = lambda^Y * e^lambda / Y!
        /// </summary>
        /// <param name="Y">The number of events we want to know the probability of happening given a known average in a given time period.</param>
        /// <param name="Lambda">The average number of events in a given time period.</param>
        /// <param name="rvt">The random variable type. Whether it is cumulative or not and which way.</param>
        public NuGenPoissonProbability(int Y, double Lambda, RandomVariableType rvt) : base(Y, rvt)
        {
            m_changes         = Y;
            m_poisson_average = Lambda;

            if (!(Y >= 0))
            {
                throw new NuGenProbabilityException("Y >=0");
            }
            if (!(Lambda >= 0))
            {
                throw new NuGenProbabilityException("Lambda >=0");
            }
        }
Esempio n. 8
0
        //public GeometricProbability(int Y=0, double p=1.0, NuGenProbability::RandomVariableType rvt=EQUAL);

        /*	The discrete geometric probability
         *      The equation for this probability is:
         *      P(Y) = (1.0-p)^(y-1) * p
         */

        /// <summary>
        /// Constructs a geometric probability
        /// </summary>
        /// <param name="Y">The number of the trial that the success occurs on. Must be 0 is less than or equal to Y</param>
        /// <param name="p">Chance of success for each trial.	Must be 0.0 is less than or equal to p which is less than or equal to 1.0</param>
        /// <param name="rvt">Random variable comparison. Whether this probability is cumulative and which way it is. </param>
        public NuGenGeometricProbability(int Y, double p, RandomVariableType rvt) : base(Y, rvt)
        {
            m_trial_of_success  = Y;
            m_chance_of_success = p;

            if (!(Y >= 0))
            {
                throw new NuGenProbabilityException("Y>=0");
            }
            if (!(p >= 0.0 && p <= 1.0))
            {
                throw new NuGenProbabilityException("p >= 0.0  && p<=1.0");
            }
        }
        //public NuGenNegativeBinomialProbability(int Y=1, int K=1, double p=0.0, NuGenProbability::RandomVariableType rvt=EQUAL);
        /// <summary>
        /// The Negative Binomial NuGenProbability
        /// The equation for this probability is:
        /// P(Y) = (Y-1)!/(((Y-1)-(K-1))!(K-1)!)*p^K*(1-p)^(Y-K)
        /// </summary>
        /// <param name="Y">number of the trial that the kth success happens; must be 0 less than or equal to Y</param>
        /// <param name="K">number of successful trials; must be 0 is less than or equal to K which is less than or equal to Y</param>
        /// <param name="p">chance of success for each trial; must be 0.0 is less than or equal to p which is less than or equal to 1.0</param>
        /// <param name="rvt">Random variable comparison. Whether this probability is cumulative and which way it is.</param>
        public NuGenNegativeBinomialProbability(int Y, int K, double p, RandomVariableType rvt) : base(Y, rvt)
        {
            m_trials            = Y;
            m_kth_success       = K;
            m_chance_of_success = p;

            if (!(0 <= Y && K >= 0))
            {
                throw new NuGenProbabilityException("0<=Y && K>=0");
            }
            if (!(p >= 0.0 && p <= 1.0))
            {
                throw new NuGenProbabilityException("p >=0.0 && p<=1.0");
            }
        }
        /*  The discrete binomial probability.
         *      The equation for this probability is:
         *      P(Y) = N!/((N-Y)!Y!)*p^Y*(1-p)^(N-Y)
         */

        #region Constructors

        /// <summary>
        /// Constructs a binomial probability
        /// </summary>
        /// <param name="N">number of trials of this experiment; must be 0 is less than or equal to N</param>
        /// <param name="Y">number of successful trials; must be 0 is less than or equal to Y which is less than or equal to N</param>
        /// <param name="p">chance of success for each trial; must be 0.0 is less than or equal to p which is less than or equal to 1.0</param>
        /// <param name="rvt">Random variable comparison. Whether this probability is cumulative and which way it is.</param>

        NuGenBinomialProbability(int N, int Y, double p, RandomVariableType rvt) : base(Y, rvt)
        {
            m_trials            = N;
            m_successes         = Y;
            m_chance_of_success = p;

            if (!(Y <= N && Y >= 0))
            {
                throw new NuGenProbabilityException("Y<=N && Y >=0");
            }
            if (!(p >= 0.0 && p <= 1.0))
            {
                throw new NuGenProbabilityException("p >=0.0 && p<=1.0");
            }
        }
		//public HyperGeometricProbability(int N=0, int n=0, int y=0, int r=0, NuGenProbability::RandomVariableType rvt=EQUAL);

		/// <summary>
		/// The HyperGeometric probability is defined by:
		/// The equation: (rCy)*((N-r)C(n-y))/(NCn)
		/// where (x C y ) represents a combination, "x choose y" 
		/// </summary>
		/// <param name="N">the population size; N must be > 0</param>
		/// <param name="n">the sample size; must be n is less than or equal to N</param>
		/// <param name="y">the sample set of items we are interested in.</param>
		/// <param name="r">the number of items from the sample set we are interested in. must be y is less than or equal to r</param>
		/// <param name="rvt">type of the random variable</param>
		public NuGenHyperGeometricProbability(int N, int n, int y, int r, RandomVariableType rvt) : base(y,rvt)
		{
			m_population=N; 
			m_sample=n; 
			m_red=y; 
			m_black=n-y;
			m_selectedset=r;

			if (!(y <= r)) throw new NuGenProbabilityException("y <= r");
			if (!(n-y <= N-r)) throw new NuGenProbabilityException("n-y <= N-r");
			if (!(y>=0)) throw new NuGenProbabilityException("y>=0");
			if (!(N>0)) throw new NuGenProbabilityException("N>0");
			if (!(r>=0)) throw new NuGenProbabilityException("r>=0");
			if (!(n>=0)) throw new NuGenProbabilityException("n>=0");
		}
Esempio n. 12
0
        public RandomVariable(RandomVariableType rvType)
        {
            switch (rvType)
            {
            case RandomVariableType.Uniform:
                this.Name = "Unifrom Random Variable";
                this.Argument.Add(new Variable(name: "X", dataType: DataType.Integer, isList: true));
                break;

            case RandomVariableType.Binomial:
                this.Name = "Binomial Random Variable";
                this.Argument.Add(new Variable(name: "r", dataType: DataType.Integer, isList: true));
                this.Argument.Add(new Variable(name: "n", dataType: DataType.Integer));
                this.Argument.Add(new Variable(name: "p", dataType: DataType.Float));
                break;

            case RandomVariableType.Poisson:
                this.Name = "Poisson Random Variable";
                this.Argument.Add(new Variable(name: "k", dataType: DataType.Integer, isList: true));
                this.Argument.Add(new Variable(name: MathSymbol.Lambda, dataType: DataType.Float));
                this.Argument.Add(new Variable(name: "w", dataType: DataType.Float, presetValue: "1"));
                break;

            case RandomVariableType.Geometric:
                this.Name = "Geometric Random Variable";
                this.Argument.Add(new Variable(name: "n", dataType: DataType.Integer));
                this.Argument.Add(new Variable(name: "p", dataType: DataType.Float));
                break;

            case RandomVariableType.NegativeBinomial:
                this.Name = "Negative Binomial Random Variable";
                this.Argument.Add(new Variable(name: "n", dataType: DataType.Integer));
                this.Argument.Add(new Variable(name: "p", dataType: DataType.Float));
                this.Argument.Add(new Variable(name: "r", dataType: DataType.Integer));
                break;

            case RandomVariableType.HyperGeometric:
                this.Name = "Hyper-Geometric Random Variable";
                this.Argument.Add(new Variable(name: "N", dataType: DataType.Integer));
                this.Argument.Add(new Variable(name: "n", dataType: DataType.Integer));
                this.Argument.Add(new Variable(name: "r", dataType: DataType.Integer));
                this.Argument.Add(new Variable(name: "k", dataType: DataType.Integer));
                break;
            }
        }
Esempio n. 13
0
        private static Label GetDescriptionLabel(RandomVariableType type)
        {
            Label descriptionLabel = new Label();
            Image labelImage       = null;

            switch (type)
            {
            case RandomVariableType.Uniform:
                labelImage = Resources.uniformRVTex;
                break;

            case RandomVariableType.Binomial:
                labelImage = Resources.binomialRVTex;
                break;

            case RandomVariableType.Poisson:
                labelImage = Resources.poissonRVTex;
                break;

            case RandomVariableType.Geometric:
                labelImage = Resources.geometricRVTex;
                break;

            case RandomVariableType.NegativeBinomial:
                labelImage = Resources.negBinomialRVTex;
                break;

            case RandomVariableType.HyperGeometric:
                labelImage = Resources.hyperGeoRVTex;
                break;
            }
            double scale      = 0.8;
            Size   scaledSize = new Size((int)(labelImage.Width * scale), (int)(labelImage.Height * scale));

            descriptionLabel.Image = (Image)(new Bitmap(labelImage, scaledSize));
            return(descriptionLabel);
        }
Esempio n. 14
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="rv">The Random Variable value.</param>
		/// <param name="rvt">Random Variable type, whether it is cumulative and which way it is cumulative.</param>
		/// <param name="prob">The probability of the event.  This can be set before hand if it is known and the GetResult function will return it.</param>
		public NuGenProbability( int rv, RandomVariableType rvt, double prob)
		{
			m_RV=rv; m_RVT=rvt; m_probability=prob;
		}
Esempio n. 15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rv">The Random Variable value.</param>
 /// <param name="rvt">Random Variable type, whether it is cumulative and which way it is cumulative.</param>
 /// <param name="prob">The probability of the event.  This can be set before hand if it is known and the GetResult function will return it.</param>
 public NuGenProbability(int rv, RandomVariableType rvt, double prob)
 {
     m_RV = rv; m_RVT = rvt; m_probability = prob;
 }
Esempio n. 16
0
 public NuGenProbability(int rv, RandomVariableType rvt) : this(rv, rvt, UNDEFINED)
 {
 }
Esempio n. 17
0
		public NuGenProbability(int rv, RandomVariableType rvt) : this(rv, rvt, UNDEFINED)
		{
						
		}