This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //-->fill(3,5) | |
| // ans = | |
| // 1. 3. 4. 9. 10. | |
| // 2. 5. 8. 11. 14. | |
| // 6. 7. 12. 13. 15. | |
| function [x] = fill(N, M) | |
| x = zeros(N, M) | |
| Z = N + M - 1 | |
| i = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //-->adiag([1 2 3 4; 5 6 7 8; 9 10 11 12],3)' | |
| // ans = | |
| // 9. 6. 3. | |
| function [v] = adiag(x, z) | |
| // 2D matrix antidiagonal | |
| [N, M] = size(x) | |
| // The total diagonals count |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function [y_out, m, sig] = ssa_normalize(y) | |
| // http://en.wikipedia.org/wiki/Student%27s_t-statistic | |
| m = mean(y) | |
| sig = sqrt(variance(y)) // stdev(y) | |
| y_out = (y - m) / sig | |
| endfunction | |
| function [y_out] = ssa(y, L, I) | |
| [LAMBDA, U, V] = ssa_decompose(y, L) | |
| y_out = ssa_reconstruct(LAMBDA, U, V, I) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import division, print_function | |
| import numpy as np | |
| import matplotlib.pyplot as pp | |
| def xcorr(a, b, mode='same'): | |
| a = np.asarray(a) | |
| b = np.asarray(b) | |
| a = a - a.mean() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import base64 | |
| code="aW1wb3J0IHB5bW9uZ28KaW1wb3J0IHVybGxpYi5yZXF1ZXN0LCB1cmxsaWIuZXJyb3IsIHVybGxpYi5wYXJzZQppbXBvcnQgaHR0cC5jb29raWVqYXIKaW1wb3J0IHJhbmRvbQppbXBvcnQgcmUKaW1wb3J0IHN0cmluZwoKIyBtYWtlcyBhIGxpdHRsZSBzYWx0CmRlZiBtYWtlX3NhbHQobik6CiAgICBzYWx0ID0gIiIKICAgIGZvciBpIGluIHJhbmdlKG4pOgogICAgICAgIHNhbHQgPSBzYWx0ICsgcmFuZG9tLmNob2ljZShzdHJpbmcuYXNjaWlfbGV0dGVycykKICAgIHJldHVybiBzYWx0CgoKIyB0aGlzIGlzIGEgdmFsaWRhdGlvbiBwcm9ncmFtIHRvIG1ha2Ugc3VyZSB0aGF0IHRoZSBibG9nIHdvcmtzIGNvcnJlY3RseS4KCmRlZiBjcmVhdGVfdXNlcih1c2VybmFtZSwgcGFzc3dvcmQpOgogICAgdHJ5OgogICAgICAgIHByaW50KCJUcnlpbmcgdG8gY3JlYXRlIGEgdGVzdCB1c2VyICIsIHVzZXJuYW1lKQogICAgICAgIGNqID0gaHR0cC5jb29raWVqYXIuQ29va2llSmFyKCkKICAgICAgICB1cmwgPSAiaHR0cDovL2xvY2FsaG9zdDo4MDgyL3NpZ251cCIKCiAgICAgICAgZGF0YSA9IHVybGxpYi5wYXJzZS51cmxlbmNvZGUoWygiZW1haWwiLCIiKSwoInVzZXJuYW1lIix1c2VybmFtZSksICgicGFzc3dvcmQiLHBhc3N3b3JkKSwgKCJ2ZXJpZnkiLHBhc3N3b3JkKV0pCiAgICAgICAgcmVxdWVzdCA9IHVybGxpYi5yZXF1ZXN0LlJlcXVlc3QodXJsPXVybCwgZGF0YT1kYXRhLmVuY29kZSgidXRmOCIpKQogICAgICAgIG9wZW5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module WingAR where | |
| import Data.Maybe | |
| import Text.Printf | |
| -- See http://en.wikipedia.org/wiki/Aspect_ratio_%28wing%29 | |
| wing_ar :: Float -> Float -> Float | |
| wing_ar l s = l^2 / s | |
| readMaybe s = listToMaybe $ fmap fst $ reads s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| class BaseSimpleDataSource<Cell: ReusableView, Collection: CollectionType | |
| where Collection.Index == Int, | |
| Collection.Generator.Element: CollectionType, | |
| Collection.Generator.Element.Index == Int, | |
| Collection.Generator.Element.Generator.Element == Cell.Model>: NSObject { | |
| typealias Item = Cell.Model |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import PureLayout | |
| extension UINib { | |
| func instantiateWithOwner<T: AnyObject>(owner: AnyObject?, options: [NSObject : AnyObject]? = nil, type: T.Type) -> T { | |
| let objs = self.instantiateWithOwner(owner, options: options) | |
| return objs.findFirst { $0 is T } as! T | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import division, print_function | |
| import numpy as np | |
| import matplotlib.pyplot as pp | |
| %matplotlib inline | |
| def xcorr(a, b, mode='same'): | |
| a = np.asarray(a) | |
| b = np.asarray(b) | |
| a = (a - a.mean()) / np.sqrt(np.correlate(a, a)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % Force GNU Octave to interpret this file as a script | |
| 1; | |
| function [y_out, m, sig] = ssa_normalize(y) | |
| % http://en.wikipedia.org/wiki/Student%27s_t-statistic | |
| m = mean(y); | |
| sig = sqrt(variance(y)) % stdev(y); | |
| y_out = (y - m) / sig; | |
| endfunction |
OlderNewer