histogram - calculate histogram

Syntax: float histogram(float x, float classes)
Description: Calculate a histogram of x using the intervals defined by classes
  • The first value returned is the number of points in x lower than the classes[1], the second value is the number of points between classes[1] and classes[2] and so on up to the last value returned which is the number of points greater than classes[n] (the last point in classes. For example if classes=1//2//3, then four intervals are used: x<1, 1<x<2, 2<x<3 and x>3.
  • A histogram in two dimensions is called a crosstable.
Example:

x

classes histogram(x,classes)
1
3
4
6
7
8
2.5
5
7.5
1
2
2
1
Sample code:
height=normrnd(100)*50+150;
classes = (1:(max(height)/10))*10;
histo = histogram(height, classes);
create Viewport page_1.viewport;
create Domain page_1.viewport.domain;
set page_1.viewport.domain.xaxis1
   ( XuNtickmarksMajorStepValue = 50,
     XuNtickmarksMinor = true,
     XuNtickmarksMinorNumber = 4
   );
create Graph page_1.viewport.domain.graph_2
   ( XuNbarOffset = 100,
     XuNgraphType = "bar",
     XuNxData = "0//classes",
     XuNyData = "histo"
   );
See also:

crosstable, crosssum, histosum,

histosum - calculate histosum

Syntax: float histosum(float x, float y, float classes)
Description: Calculate a histogram of x using the sum of y and the intervals defined by classes
  • histosum works in the same way as histogram, see above, except that instead of counting the number of x values in each interval, Gsharp sums the corresponding values of y.
  • A histosum in two dimensions is called a crosssum.
Example:

x

y classes histosum(x,y,classes)
1
3
4
6
7
8
1
10
100
1000
10000
100000
2.5
5
7.5
1
110
11000
100000
See also:

crosstable, crosssum, histogram,

hournumber - return hour part of a time

Syntax: float hournumber(time t)
Description: Return the hour part of a time dataset t.
  • t can either be a time dataset or a string in one of the formats supported by the function timeformat1.
Example: t hournumber(t)
12:00:00
14:59:59
12
14
Sample code:
function set_hands()
  T = time;
  SecondHand = secondnumber(T)*6;
  BigHand    = (360*minutenumber(T)+SecondHand)/60;
  LittleHand = (360*hournumber(T)+BigHand)/12;
endfunction
See also:

minutenumber, secondnumber, totime

hourrange - return time range

Syntax: time hourrange(time times, float hstep)
Description:

Return a range of times which can be found within the extremes of times and are an integer multiple of hstep hours since midnight

  • times can either be a time dataset or a string in one of the formats supported by the function timeformat1.
Example: times hourrange(times,3)
9:02:01
12:00:00
19:02:01
12:00:00
15:00:00
18:00:00
See also:

minuterange, secondrange, midhourrange