Documentation ¶
Overview ¶
Package tserie generate time series data
Index ¶
- func Cos(period time.Duration, amplitude, vshift float64) func(time.Time) float64
- func Normal(std, mean float64) func(time.Time) float64
- func Sin(period time.Duration, amplitude, vshift float64) func(time.Time) float64
- func Sine(period time.Duration, amplitude, vshift float64) func(time.Time) float64
- type Point
- type TimeIterator
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cos ¶ added in v0.3.0
Cos as y = amplitude*sin(frequency * relativeTime)+vshift
Example ¶
ExampleCos generates a cosinusoidal function with period of one hour and samples every one minute
package main import ( "fmt" "time" "github.com/licaonfee/tserie" ) func main() { start := time.Date(2022, 6, 26, 0, 0, 0, 0, time.UTC) stop := time.Date(2022, 6, 26, 1, 0, 0, 0, time.UTC) step := time.Minute value := tserie.Sin(time.Hour, 1, 0) ts := tserie.MakeTS(start, stop, step, value) for _, t := range ts { fmt.Printf("%02d = %.02f\n", t.Time.Minute(), t.Value) } }
Output: 00 = 0.00 01 = 0.10 02 = 0.21 03 = 0.31 04 = 0.41 05 = 0.50 06 = 0.59 07 = 0.67 08 = 0.74 09 = 0.81 10 = 0.87 11 = 0.91 12 = 0.95 13 = 0.98 14 = 0.99 15 = 1.00 16 = 0.99 17 = 0.98 18 = 0.95 19 = 0.91 20 = 0.87 21 = 0.81 22 = 0.74 23 = 0.67 24 = 0.59 25 = 0.50 26 = 0.41 27 = 0.31 28 = 0.21 29 = 0.10 30 = 0.00 31 = -0.10 32 = -0.21 33 = -0.31 34 = -0.41 35 = -0.50 36 = -0.59 37 = -0.67 38 = -0.74 39 = -0.81 40 = -0.87 41 = -0.91 42 = -0.95 43 = -0.98 44 = -0.99 45 = -1.00 46 = -0.99 47 = -0.98 48 = -0.95 49 = -0.91 50 = -0.87 51 = -0.81 52 = -0.74 53 = -0.67 54 = -0.59 55 = -0.50 56 = -0.41 57 = -0.31 58 = -0.21 59 = -0.10 00 = 0.00
func Sin ¶ added in v0.3.0
Sin as y = amplitude*sin(frequency * relativeTime)+vshift
Example ¶
ExampleSin generates a sinusoidal function with period of one hour and samples every one minute
package main import ( "fmt" "time" "github.com/licaonfee/tserie" ) func main() { start := time.Date(2022, 6, 26, 0, 0, 0, 0, time.UTC) stop := time.Date(2022, 6, 26, 1, 0, 0, 0, time.UTC) step := time.Minute value := tserie.Sin(time.Hour, 1, 0) ts := tserie.MakeTS(start, stop, step, value) for _, t := range ts { fmt.Printf("%02d = %.02f\n", t.Time.Minute(), t.Value) } }
Output: 00 = 0.00 01 = 0.10 02 = 0.21 03 = 0.31 04 = 0.41 05 = 0.50 06 = 0.59 07 = 0.67 08 = 0.74 09 = 0.81 10 = 0.87 11 = 0.91 12 = 0.95 13 = 0.98 14 = 0.99 15 = 1.00 16 = 0.99 17 = 0.98 18 = 0.95 19 = 0.91 20 = 0.87 21 = 0.81 22 = 0.74 23 = 0.67 24 = 0.59 25 = 0.50 26 = 0.41 27 = 0.31 28 = 0.21 29 = 0.10 30 = 0.00 31 = -0.10 32 = -0.21 33 = -0.31 34 = -0.41 35 = -0.50 36 = -0.59 37 = -0.67 38 = -0.74 39 = -0.81 40 = -0.87 41 = -0.91 42 = -0.95 43 = -0.98 44 = -0.99 45 = -1.00 46 = -0.99 47 = -0.98 48 = -0.95 49 = -0.91 50 = -0.87 51 = -0.81 52 = -0.74 53 = -0.67 54 = -0.59 55 = -0.50 56 = -0.41 57 = -0.31 58 = -0.21 59 = -0.10 00 = 0.00
Types ¶
type TimeIterator ¶
type TimeIterator struct {
// contains filtered or unexported fields
}
TimeIterator generates datapoints in the same way as MakeTS but is suitable for big datasets
func NewTimeIterator ¶
func NewTimeIterator(start, stop time.Time, step time.Duration, gen func(time.Time) float64) *TimeIterator
NewTimeIterator creates a new TimeIterator
func (*TimeIterator) Item ¶
func (it *TimeIterator) Item() Point
Item returns the current data point
func (*TimeIterator) Next ¶
func (it *TimeIterator) Next() bool
Next returns true while current time is before stop
Click to show internal directories.
Click to hide internal directories.