forum.alglib.net

ALGLIB forum
It is currently Thu Mar 28, 2024 8:10 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 13 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: studenttdistribution
PostPosted: Wed Nov 06, 2013 12:59 pm 
Offline

Joined: Wed Nov 06, 2013 12:55 pm
Posts: 8
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.


Top
 Profile  
 
 Post subject: Re: studenttdistribution
PostPosted: Thu Nov 07, 2013 10:55 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 903
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.


Top
 Profile  
 
 Post subject: Re: studenttdistribution
PostPosted: Thu Nov 07, 2013 11:07 am 
Offline

Joined: Wed Nov 06, 2013 12:55 pm
Posts: 8
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


Top
 Profile  
 
 Post subject: Re: studenttdistribution
PostPosted: Thu Nov 07, 2013 11:20 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 903
Can you catch this exception and print out its description,which is stored in msg field?


Top
 Profile  
 
 Post subject: Re: studenttdistribution
PostPosted: Thu Nov 07, 2013 11:30 am 
Offline

Joined: Wed Nov 06, 2013 12:55 pm
Posts: 8
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


Top
 Profile  
 
 Post subject: Re: studenttdistribution
PostPosted: Thu Nov 07, 2013 12:52 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 903
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...


Top
 Profile  
 
 Post subject: Re: studenttdistribution
PostPosted: Thu Nov 07, 2013 1:10 pm 
Offline

Joined: Wed Nov 06, 2013 12:55 pm
Posts: 8
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!


Top
 Profile  
 
 Post subject: Re: studenttdistribution
PostPosted: Fri Nov 08, 2013 8:35 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 903
What of your parameters denotes "degrees of freedom"? "Student" or "ddl"?


Top
 Profile  
 
 Post subject: Re: studenttdistribution
PostPosted: Fri Nov 08, 2013 8:54 am 
Offline

Joined: Wed Nov 06, 2013 12:55 pm
Posts: 8
Good morning,
"degrees of freedom" = "ddl"


Top
 Profile  
 
 Post subject: Re: studenttdistribution
PostPosted: Sun Nov 10, 2013 8:31 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 903
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 45 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group