(* ::Package:: *)

BeginPackage["Hurt`Stat2`","Histograms`"]
(* usage messages for the exported functions and the context itself *)


datareport::usage = "datareport[data,noclass] returns the basic statistical characteristics and the histogram of the data. Data should be in the form of vector. Variable noclass should be a positive integer and is the number of the categories for the histogram. If missing, the default value is set to 10."


datareport::baddata = "Argument `1` should be a vector!"
datareport::badclasses = "Argument `2` should be a positive integer!"


Begin["`Private`"]    (* begin the private context (implementation part) *)
(* Clear[datareport]; *)


datareport[data_,noclass_:10]:=Module[{mi=Min[data],ma=Max[data],bin,h,k,le,mea,med,se},
k=noclass;
If[Not[VectorQ[data]],Message[datareport::baddata]];
If[Not[IntegerQ[k]&&k>0],Message[datareport::badclasses,k]];
bin=BinCounts[data,{mi,ma,h=(ma-mi)/k}];Print["No. = ",le=Length[data],"\nMin = ",mi," Max = ",ma,"\nMean= ",mea=Mean[data]," Median = ",med=Median[data],"\nSE = ",se=StandardDeviation[data]," VaR 5% = ",Quantile[data,0.05`]," VaR 1% = ",Quantile[data,0.01`]];Histogram[data,HistogramCategories->k,(* BarStyle->{GrayLevel[0.95`]}, *)ApproximateIntervals->True]]


End[ ]         (* end the private context *)


EndPackage[ ]  (* end the package context *)
