00001
00002
00003
00004 #include "TMath.h"
00005 #include "TF1.h"
00006 #include "TCanvas.h"
00007 #include <Riostream.h>
00008 #include "TLegend.h"
00009 #include "TLegendEntry.h"
00010
00011 void mathStudent()
00012 {
00013
00014
00015 TCanvas *DistCanvas = new TCanvas("DistCanvas", "Distribution graphs", 10, 10, 1000, 800);
00016 DistCanvas->SetFillColor(17);
00017 DistCanvas->Divide(2, 2);
00018 DistCanvas->cd(1);
00019 gPad->SetGrid();
00020 gPad->SetFrameFillColor(19);
00021 TLegend *leg = new TLegend(0.6, 0.7, 0.89, 0.89);
00022
00023
00024 TF1* fgaus = new TF1("gaus", "TMath::Gaus(x, [0], [1], [2])", -5, 5);
00025 fgaus->SetTitle("Student density");
00026 fgaus->SetLineStyle(2);
00027 fgaus->SetLineWidth(1);
00028 fgaus->SetParameters(0, 1, kTRUE);
00029 leg->AddEntry(fgaus->DrawCopy(), "Normal(0,1)", "l");
00030
00031 TF1* student = new TF1("student", "TMath::Student(x,[0])", -5, 5);
00032
00033 student->SetLineWidth(1);
00034 student->SetParameter(0, 10);
00035 student->SetLineColor(4);
00036 leg->AddEntry(student->DrawCopy("lsame"), "10 degrees of freedom", "l");
00037
00038 student->SetParameter(0, 3);
00039 student->SetLineColor(2);
00040 leg->AddEntry(student->DrawCopy("lsame"), "3 degrees of freedom", "l");
00041
00042 student->SetParameter(0, 1);
00043 student->SetLineColor(1);
00044 leg->AddEntry(student->DrawCopy("lsame"), "1 degree of freedom", "l");
00045
00046 leg->Draw();
00047
00048
00049 DistCanvas->cd(2);
00050 gPad->SetFrameFillColor(19);
00051 gPad->SetGrid();
00052 TF1 *studentI = new TF1("studentI", "TMath::StudentI(x, [0])", -5, 5);
00053 studentI->SetTitle("Student cumulative dist.");
00054 studentI->SetLineWidth(1);
00055 TLegend *leg2 = new TLegend(0.6, 0.4, 0.89, 0.6);
00056
00057 studentI->SetParameter(0, 10);
00058 studentI->SetLineColor(4);
00059 leg2->AddEntry(studentI->DrawCopy(), "10 degrees of freedom", "l");
00060
00061 studentI->SetParameter(0, 3);
00062 studentI->SetLineColor(2);
00063 leg2->AddEntry(studentI->DrawCopy("lsame"), "3 degrees of freedom", "l");
00064
00065 studentI->SetParameter(0, 1);
00066 studentI->SetLineColor(1);
00067 leg2->AddEntry(studentI->DrawCopy("lsame"), "1 degree of freedom", "l");
00068 leg2->Draw();
00069
00070
00071 TF1* fDist = new TF1("fDist", "TMath::FDist(x, [0], [1])", 0, 2);
00072 fDist->SetTitle("F-Dist. density");
00073 fDist->SetLineWidth(1);
00074 TLegend* legF1 = new TLegend(0.7, 0.7, 0.89, 0.89);
00075
00076 DistCanvas->cd(3);
00077 gPad->SetFrameFillColor(19);
00078 gPad->SetGrid();
00079
00080 fDist->SetParameters(1, 1);
00081 fDist->SetLineColor(1);
00082 legF1->AddEntry(fDist->DrawCopy(), "N=1 M=1", "l");
00083
00084 fDist->SetParameter(1, 10);
00085 fDist->SetLineColor(2);
00086 legF1->AddEntry(fDist->DrawCopy("lsame"), "N=1 M=10", "l");
00087
00088 fDist->SetParameters(10, 1);
00089 fDist->SetLineColor(8);
00090 legF1->AddEntry(fDist->DrawCopy("lsame"), "N=10 M=1", "l");
00091
00092 fDist->SetParameters(10, 10);
00093 fDist->SetLineColor(4);
00094 legF1->AddEntry(fDist->DrawCopy("lsame"), "N=10 M=10", "l");
00095
00096 legF1->Draw();
00097
00098
00099 TF1* fDistI = new TF1("fDist", "TMath::FDistI(x, [0], [1])", 0, 2);
00100 fDistI->SetTitle("Cumulative dist. function for F");
00101 fDistI->SetLineWidth(1);
00102 TLegend* legF2 = new TLegend(0.7, 0.3, 0.89, 0.5);
00103
00104 DistCanvas->cd(4);
00105 gPad->SetFrameFillColor(19);
00106 gPad->SetGrid();
00107 fDistI->SetParameters(1, 1);
00108 fDistI->SetLineColor(1);
00109 legF2->AddEntry(fDistI->DrawCopy(), "N=1 M=1", "l");
00110
00111 fDistI->SetParameters(1, 10);
00112 fDistI->SetLineColor(2);
00113 legF2->AddEntry(fDistI->DrawCopy("lsame"), "N=1 M=10", "l");
00114
00115 fDistI->SetParameters(10, 1);
00116 fDistI->SetLineColor(8);
00117 legF2->AddEntry(fDistI->DrawCopy("lsame"), "N=10 M=1", "l");
00118
00119 fDistI->SetParameters(10, 10);
00120 fDistI->SetLineColor(4);
00121 legF2->AddEntry(fDistI->DrawCopy("lsame"), "N=10 M=10", "l");
00122
00123 legF2->Draw();
00124 DistCanvas->cd();
00125 }
00126
00127