commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rosie Chandler <rosie.chand...@btopenworld.com>
Subject Re: Using the cumulative probability distribution method
Date Mon, 29 May 2006 11:33:22 GMT
Thankyou for your help.

I have successfully compiled your suggested code, but
when I try to run it I get the following error:

Exception in thread "main"
java.lang.NoClassDefFoundError:
org/apache/commons/math/MathException

Is there anything else that I have missed out?  I am
compiling the code with the commons-math-1.1.jar in
the classpath.

--- luc.maisonobe@free.fr wrote:

> Selon Rosie Chandler
> <rosie.chandler@btopenworld.com>:
> 
> > I'm trying to use the cumulativeProbability method
> on
> > a normal distribution, but I can't get it to work
> > (sorry, but I'm new to Java and I just need to use
> it
> > to complete one task.  Here is my code:
> 
> Exceptions are the standard way errors are handled
> in the java language. In this
> case, the cumulativeProbability method in class
> NormalDistribution may throw
> such an exception, so it must be handled by the
> calling function (or one of the
> upper level caller if it declares to let the
> exception go up).
> 
> To correct this, you should first add an import
> statement for the exception
> class, and second handle it thanks to a try/catch
> statement. Here is your
> complete example reworked:
> 
> 
> 
> 
> 
> import org.apache.commons.math.distribution.*;
> import org.apache.commons.math.MathException;
> 
> public class testProj
> {
>         public static void main(String[] args)
>         {
>           try {
>                 DistributionFactory factory =
> DistributionFactory.newInstance();
>                 NormalDistribution NormDistn =
> factory.createNormalDistribution();
> 
>                 double value =
> NormDistn.cumulativeProbability(1.0);
>                 System.out.println(value);
>           } catch (MathException me) {
>             System.err.println(me.getMessage());
>             System.exit(1);
>           }
>         }
> }
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message