Given a list `x` a sample of length ``n`` of that list is returned. For example, if `n` is 10, and `x` has 100 items, a list of every tenth. item is returned. ``k`` can be used as offset.
(x, n, k=0)
| 100 | |
| 101 | |
| 102 | def sample(x, n, k=0): |
| 103 | """Given a list `x` a sample of length ``n`` of that list is returned. |
| 104 | |
| 105 | For example, if `n` is 10, and `x` has 100 items, a list of every tenth. |
| 106 | item is returned. |
| 107 | |
| 108 | ``k`` can be used as offset. |
| 109 | """ |
| 110 | j = len(x) // n |
| 111 | for _ in range(n): |
| 112 | try: |
| 113 | yield x[k] |
| 114 | except IndexError: |
| 115 | break |
| 116 | k += j |
| 117 | |
| 118 | |
| 119 | def hfloat(f, p=5): |