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
{-# LANGUAGE FlexibleContexts #-} | |
-- Version 2.0 | |
import Data.Ratio | |
(*!) _ 0 = 0 | |
(*!) a b = a*b | |
(^+) a b = zipWith (+) a b |
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
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
-- Uses exact-real package | |
import Data.Ratio | |
import Data.CReal | |
(*!) _ 0 = 0 | |
(*!) a b = a*b |
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 Data.Ratio | |
(^+) a b = zipWith (+) a b | |
(^-) a b = zipWith (-) a b | |
(a : as) `convolve` (b : bs) = (a * b) : | |
((map (a *) bs) ^+ (as `convolve` (b : bs))) | |
compose (f : fs) (0 : gs) = f : (gs `convolve` (compose fs (0 : gs))) |
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
# -*- coding: utf-8 -*- | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import scipy.integrate as integrate | |
# Dimension of image in pixels | |
N = 256 | |
# Number of samples to use for integration | |
M = 33 |
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
# -*- coding: utf-8 -*- | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import scipy.integrate as integrate | |
# Dimension of image in pixels | |
N = 256 | |
# Number of samples to use for integration | |
M = 257 |
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
# -*- coding: utf-8 -*- | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import scipy.integrate as integrate | |
# Dimension of image in pixels | |
N = 256 | |
# Number of samples to use for integration | |
M = 257 |
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
# -*- coding: utf-8 -*- | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import random | |
import scipy.integrate as integrate | |
# Dimension of image in pixels | |
N = 129 | |
# Number of samples to use for integration |
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 Data.Ratio | |
import Data.List | |
import Control.Monad | |
-- I'm using two Haskell types for the two vertex types in | |
-- a bipartite graph. | |
-- Edges only go from type a to type b. | |
data BipartiteGraph a b = G [a] [b] [(a, b)] | |
instance (Show a, Show b) => Show (BipartiteGraph a b) where |
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
{-# LANGUAGE FlexibleContexts #-} | |
import Data.Array | |
import Data.Array.IO | |
import Data.Foldable | |
import Data.List hiding (sum) | |
import System.Random | |
import Control.Monad.State | |
import Prelude hiding (sum) | |
--import Debug.Trace |
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 dm(Pa, Pb, y, β, n) | |
for i in 1:n | |
if i%100 == 0 | |
print("Iteration $i/$n\n") | |
end | |
fay = (1-1/β)*Pa(y)+(1/β)*y | |
fby = (1+1/β)*Pb(y)-(1/β)*y | |
y = y+β*(Pa(fby)-Pb(fay)) | |
# @show(y) | |
end |