1
Good morning, I’m having a problem calculating the Z-value in the normal distribution. Also the calculation of t and sigma t constants are giving me 0, which is impossible. I’ll put the code and output.
The calculation can be seen on the following website: http://www.portalaction.com.br/probabilidades/62-distribuicao-normal
Surely in java you can calculate, I’ve been doing some research and I found a method but it’s not working very well.
The code I’m using is:
import java.io.*;
import static java.lang.Math.sqrt;
import org.apache.commons.math.distribution.NormalDistribution;
import org.apache.commons.math.distribution.NormalDistributionImpl;
public static void main(String[] args) throws MathException
{
//constantes
double PARAGEM=0.1; //crit. paragem função objetivo
int ITERACOES=90; //nº max de iterações
int ESPERA; //tempo máximo de espera
//variáveis
double A=80000; //custo de encomenda (euros)
double C1=40000; //custo de compra (euros/ton)
double C2=16000; //custo de stocagem (euros/ton)
double C3=150000; //custo de roptura (euros/ton)
double r=44.4; //procura média (ton/ano)
double sigma2=0.001; //variância da procura (ton/ano)
double t=(60/365); //tempo medio de reposição (anos) **//NOTA: Esta conta está a dar-me 0, não percebo porquê**
double sigmat=(20/365); //desvio padrão do tempo de reposição (anos) **//NOTA: Esta conta está a dar-me 0, não percebo porquê**
String distribuicao;
//cálculo do lote otimo (diferente para a 1ª iteração)
double Q1;
Q1=(sqrt((2*A*r)/C2));
//calculo de alfa
double alfa1;
alfa1=(C2*Q1)/C3/r;
//calculo de z1
//NormalDistributionImpl recebe média, desvio padrão
NormalDistributionImpl z1=new NormalDistributionImpl(r,sigma2);
z1.inverseCumulativeProbability(1-alfa1);
System.out.println("O valor de Q1 é "+ Q1);
System.out.println("O valor de alfa1 é "+ alfa1);
System.out.println("O valor de Z1 é "+ z1);
Output
The value of Q1 is 21.071307505705477 The value of alpha 1 is 0.05062175977346662 The value of Z1 is org.apache.Commons.math.Distribution.Normaldistributionimpl@36ed5ba6 The value of t is 0.0 The sigmat value is 0.0 BUILD SUCCESSFUL (total time: 0)
Can someone help me?
Thank you
Thank you for the previous reply which was quite useful. Z is supposed to be giving 1.638854721 Because in Excel it is much easier, just do: INV.NORMP(1-alpha 1) (in excel in Portuguese) or NORMSINV(1-alpha 1) (in excel in English) This function returns the value of the cumulative function of the standard normal. alpha= 0.051 1-alpha=0.949 INV.NORMP(0.949)= 1.6388 This function is not returning this, I’m trying to find the equivalent function in java.
– Bruno Silva