forum.alglib.net
http://forum.alglib.net/

studenttdistribution
http://forum.alglib.net/viewtopic.php?f=2&t=1046
Page 1 of 2

Author:  ThEagle [ Wed Nov 06, 2013 12:59 pm ]
Post subject:  studenttdistribution

Hello evryone!
I am trying to use studenttdistribution from statistic.h but i have a problem.
double studenttdistribution(ae_int_t k, double t, ae_state *_state);
i don't undestand what is the ae_state and what is the syntax to use if we want to asign a state.
PS: I am a beginner in the c++ programmation.

Author:  Sergey.Bochkanov [ Thu Nov 07, 2013 10:55 am ]
Post subject:  Re: studenttdistribution

You tried to use studenttdistribution from alglib_impl namespace, but it is internal namespace which should not be accessed by external code. You should use alglib::studenttdistribution function, which lacks ae_state parameter.

Author:  ThEagle [ Thu Nov 07, 2013 11:07 am ]
Post subject:  Re: studenttdistribution

Hello,
Thank you for answering!
But i still have a problem.
In my code i have : Probabilite = alglib::studenttdistribution(Student,ddl);
when i execute the program i have:
terminate called after throwing an instance of 'alglib::ap_error

Author:  Sergey.Bochkanov [ Thu Nov 07, 2013 11:20 am ]
Post subject:  Re: studenttdistribution

Can you catch this exception and print out its description,which is stored in msg field?

Author:  ThEagle [ Thu Nov 07, 2013 11:30 am ]
Post subject:  Re: studenttdistribution

Here is my code:

#include <iostream>

using namespace std;

#include <iostream>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stdlib.h>
#include "statistics.cpp"
#include "specialfunctions.cpp"
#include "linalg.cpp"
#include "alglibinternal.cpp"
#include "alglibmisc.cpp"
#include "ap.cpp"
#include "dataanalysis.cpp"
#include "diffequations.cpp"
#include "fasttransforms.cpp"
#include "integration.cpp"
#include "interpolation.cpp"
#include "optimization.cpp"
#include "solvers.cpp"
#include <stdafx.h>
#include <cmath>

using namespace std;
using namespace alglib;
using namespace alglib_impl;


int main()
{
cout << "Effectif 1:" << endl;

float Effectif1(0);

cin >> Effectif1;

cout << "Effectif 2:" << endl;

float Effectif2(0);

cin >> Effectif2;

cout << "Pourcentage 1:" << endl;

float Pourcentage1(0);

cin >> Pourcentage1;

cout << "Pourcentage 2:" << endl;

float Pourcentage2(0);

cin >> Pourcentage2;


float a(0), b(0), c(0), d(0), Student(0) ;

a = Effectif1;
b = Effectif2;
c = Pourcentage1/100;
d = Pourcentage2/100;
Student = (c - d)/sqrt((c*(1-c))/a +((d*(1-d))/b));

cout << "Student:" <<Student << endl;

float Probabilite(0), e(0), ddl(0);

e = a + b;
ddl = e - 2;

//Probabilite = alglib_impl::studenttdistribution(Student,ddl,NULL);

Probabilite = alglib::studenttdistribution(Student, ddl);

cout << "Probabilite: " << Probabilite << endl;

if(fabs(Student)>2.580)
{
cout << "Significativite : +++ " << endl;
} ;

if(fabs(Student)>1.960 && (fabs(Student)<2.580))
{
cout << "Significativite : ++ " << endl;
} ;

if((fabs(Student)>1.645) && (fabs(Student)<1.960))
{
cout << "Significativite : + " << endl;
} ;
if(fabs(Student)<1.645)
{
cout << "Significativite : Not significant " << endl;
} ;

return 0;

}

________________________________________________________________________________________________________________
When i execute i have:

Effectif 1:
100
Effectif 2:
100
Pourcentage 1:
45
Pourcentage 2:
51
Student:-0.850743
terminate called after throwing an instance of 'alglib::ap_error

It doesn't calculate the probability

Author:  Sergey.Bochkanov [ Thu Nov 07, 2013 12:52 pm ]
Post subject:  Re: studenttdistribution

It seems that you specified arguments in wrong order. Degrees of freedom should be first, and t-value should be second. BTW, you may be able to find it out if you read message returned by ap_error...

Author:  ThEagle [ Thu Nov 07, 2013 1:10 pm ]
Post subject:  Re: studenttdistribution

I don't think that it was in the wrong order. I tried to compare my values with the tables. I didn't have the same result.
I think that in studenttdistribution the first argument must be an integer et the second a double. My problem is that my Student is a float.
What can i do to change this?
If i define Student as an integer it won't show me the good result. For example, if the student's result is 0.85, the program will give Student = 0
I really need your help!

Author:  Sergey.Bochkanov [ Fri Nov 08, 2013 8:35 am ]
Post subject:  Re: studenttdistribution

What of your parameters denotes "degrees of freedom"? "Student" or "ddl"?

Author:  ThEagle [ Fri Nov 08, 2013 8:54 am ]
Post subject:  Re: studenttdistribution

Good morning,
"degrees of freedom" = "ddl"

Author:  Sergey.Bochkanov [ Sun Nov 10, 2013 8:31 am ]
Post subject:  Re: studenttdistribution

Then http://www.alglib.net/translator/man/manual.cpp.html#sub_studenttdistribution tells you that degrees of freedoms - integer parameter k - is first in the list of function parameters. And you passed ddl as second parameter.

Page 1 of 2 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/