Created
August 2, 2014 04:45
-
-
Save hexgnu/632c709a866610af66ec to your computer and use it in GitHub Desktop.
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
(define (runif) (- (* 2 (random)) 1)) | |
(define (rnormish) (+ (runif) (runif) (runif) (runif))) | |
(define xs0 (build-list 100 (λ _ (rnormish)))) | |
(define ys0 (build-list 100 (λ _ (rnormish)))) | |
(define mags (map (λ (x y) (sqrt (+ (sqr x) (sqr y)))) | |
xs0 ys0)) | |
(define xs (map / xs0 mags)) | |
(define ys (map / ys0 mags)) | |
(define ys2 (map (λ (x d) (/ x d 2)) ys0 mags)) | |
(define xs2 (map (λ (x d) (/ x d 2)) xs0 mags)) | |
(plot (list | |
(points (map vector xs ys) #:sym 'dot #:size 20) | |
(points (map vector xs2 ys2)) | |
) #:title "Cannot separate these with a line") | |
(plot3d (list | |
(points3d (map (λ (x y) (vector (sqr x) (* (sqrt 2) x y) (sqr y))) xs ys) #:sym 'dot #:size 20 #:label "x^2 + y^2 = 1") | |
(surface3d (λ (x y) (- 0.5 x)) -1 1 -1 1 | |
#:label "z = 0.5 - x" #:alpha 0.5 #:color 'yellow) | |
(points3d (map (λ (x y) (vector (sqr x) (* (sqrt 2) x y) (sqr y))) xs2 ys2) #:label "x^2 + y^2 = 0.5") | |
) #:title "Transform x,y to <x^2, sqrt(2)*x*y, y^2>" #:angle 346 #:altitude 13) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment