BasDescriptiveStatistics.StandardDeviation
This property shows Standard Deviation.
C++ Example
Running Basic Statistics in C++:
//The following example will retrieve the total and available amounts of memory
//available (categorized by physical, page file, and virtual memory). Next,
//descriptive statistics are run on the two variables (total memory and available
//memory). Finally, the variables are totaled and the sum is appended to the spreadsheet.
#include <windows.h>
#include <comdef.h> //needed for COM
//The "#import" directive imports the class library information of the
//specified file. In this case, the file "statist.exe" will give us access to the
//Statistica interface and its documents' library. You will either need to include
//this file in your project directory, or hard code the full path to the file in the
//#import directive. Lastly, note that "#import" is a Visual C++ compiler specific
//directive; if you are using a different compiler, then please consult your compiler's
//documentation on how to import a COM interface.
#import "statist.exe"
#import "sta_bas.dll"
//Exclude rarely-used stuff from Windows headers
#define WIN32_LEAN_AND_MEAN
#define MEGABYTE 1048576 //2^20
#include <cstdio>using namespace STATISTICA;using namespace STABasicStatistics;
int main()
{
//retrieve information about the current memory status
MEMORYSTATUS Memory;
::GlobalMemoryStatus (&Memory);
//Physical memorylong TotalPhyMem = static_cast<long>(Memory.dwTotalPhys/MEGABYTE);
long FreePhyMem = static_cast<long>(Memory.dwAvailPhys/MEGABYTE);
//Page file
long TotalPageFile = static_cast<long>(Memory.dwTotalPageFile/MEGABYTE);
long FreePageFile = static_cast<long>(Memory.dwAvailPageFile/MEGABYTE);
//Virtual memorylong TotalVirtMem = static_cast<long>(Memory.dwTotalVirtual/MEGABYTE);
long FreeVirtMem = static_cast<long>(Memory.dwAvailVirtual/MEGABYTE);
long TotalAvailMem = TotalPhyMem + TotalPageFile + TotalVirtMem;
long TotalFreeMem = FreePhyMem + FreePageFile + FreeVirtMem;
//Launch STATISTICA
//Initialize COM
::CoInitialize(NULL);
STATISTICA::_ApplicationPtr pApp;
//initialize a new STATISTICA object through COM
HRESULT hr = ::CoCreateInstance(__uuidof(STATISTICA::Application),NULL,CLSCTX_SERVER,
__uuidof(STATISTICA::_Application),reinterpret_cast<void**>(&pApp));
//verify that COM was able to create an instance of STATISTICA
if (FAILED(hr))
{
::MessageBox(NULL,L"Unable to intialize STATISTICA",
L"Initialization Failure",MB_ICONHAND);
return EXIT_FAILURE;
}
try
{
//Pass in login information if Enterprise is installed.
//You will need to customize this for your system.
pApp->SWSInfo(L"Isabelle", L"password123",L"", L"", L"", L"");
//create a new spreadsheet named "Current Memory"
_SpreadsheetPtr pSpreadSheet = pApp->Spreadsheets->New(L"Current Memory");
pSpreadSheet->Header->PutValue(L"Total and Available Computer Memory");
//increase the width of the cases
pSpreadSheet->PutCaseNameWidth(1.5);
//rename the first two variables
pSpreadSheet->PutVariableName(1,L"Total");
pSpreadSheet->PutVariableName(2,L"Available");
//rename the first three cases
pSpreadSheet->PutCaseName(1,L"Physical Memory");
pSpreadSheet->PutCaseName(2,L"Page File Memory");
pSpreadSheet->PutCaseName(3,L"Virtual Memory");
//fill the spreadsheet with our calculated data
pSpreadSheet->PutValue(1,1,TotalPhyMem);
pSpreadSheet->PutValue(1,2,FreePhyMem);
pSpreadSheet->PutValue(2,1,TotalPageFile);
pSpreadSheet->PutValue(2,2,FreePageFile);
pSpreadSheet->PutValue(3,1,TotalVirtMem);
pSpreadSheet->PutValue(3,2,FreeVirtMem);
//remove the extra cases and variables
pSpreadSheet->DeleteVariables(3,10);
pSpreadSheet->DeleteCases(4,10);
pSpreadSheet->Visible = true;
//run descriptive statistics on the dataset
_AnalysisPtr pBasDiag = pApp->Analysis(scBasicStatistics);
pBasDiag->Run();
BasDescriptiveStatisticsPtr pBasDesc = pBasDiag->Dialog;
//analyze both variables
pBasDesc->PutVariables("1 2");
//all of the defaults except std. dev. will be used
pBasDesc->StandardDeviation = false;
//also include sum, range, and median
pBasDesc->Sum = true;
pBasDesc->Range = true;
pBasDesc->Median = true;
//process the analysis output
pBasDiag->GetRouteOutput(pBasDesc->Summary.GetInterfacePtr())->PutVisible(true);
pBasDiag->Close();
//append our own custom statistics (sums) to the dataset
pSpreadSheet->AddCases(3,1);
pSpreadSheet->PutCaseName(4,L"Totals:");
pSpreadSheet->PutValue(4,1,TotalAvailMem);
pSpreadSheet->PutValue(4,2,TotalFreeMem);
}
catch(_com_error Err)
{
::MessageBox(NULL,Err.Description(),pApp->Name,MB_ICONHAND);
return EXIT_FAILURE;
}
//clean up after the COM initialization
pApp.Release();
::CoUninitialize();
return EXIT_SUCCESS;
}
Copyright © 2020. Cloud Software Group, Inc. All Rights Reserved.
