One Dimensional Particles¶

I created a file with the distances (from left to right) to the nearest particle to attempt to determine what the distribution of distances are as the distances appear larger toward the ends ..

In [1]:
:opt no-lint
In [2]:
import qualified Data.ByteString as B
import Text.Printf
import System.Process (createProcess,callCommand,std_out,StdStream( CreatePipe ),shell)
import IHaskell.Display
import qualified Data.ByteString as B
In [3]:
findDeltas :: [Float] -> [Float]
findDeltas fs =
   let fs' = drop 1 fs
   in map (\(f1,f2) -> (f1-f2)) (zip fs fs')
In [4]:
runGNUPlot :: String -> String -> String -> String -> String -> IO B.ByteString 
runGNUPlot dataIn title xLabel yLabel fileNameOut = do
    let gnuStr = unlines commands
    let pltFile = "cmds.plt"
    writeFile pltFile  gnuStr
    callCommand ("gnuplot " ++ pltFile)
    B.readFile fileNameOut

  where
    commands :: [String]
    commands = [
      --  "set terminal pngcairo  transparent enhanced font \
      --           \ \"arial,10\" fontscale 1.1 size 600, 400 "
        "set terminal png  \
                \ fontscale 1.1 size 600, 400 "
      , "set output " ++ "\"" ++ fileNameOut ++ "\"" 
      , "set object rectangle from screen 0,0 to screen 1,1 behind fillcolor rgb 'white' fillstyle solid noborder"
      , "set grid"
      , "unset key"
      , "set lmargin 15"
      --, "set grid"
      --, "show grid"
      , "set title  " ++ "\"" ++ title ++ "\"" ++ " textcolor lt -1 "

      , "set xlabel " ++ "\"" ++ xLabel  ++ "\"" ++  " off 0,0"
      , "set ylabel " ++ "\"" ++ yLabel  ++ "\"" ++  " off 0,0"
      , "set yrange [-70:70]"
      , "set grid"
      --, "set label 1 at 5,-13 \"55 + 55 * e^{x/5}\" center rotate by 20 front"
      --, "set label 2 at 10,5 '\\hl{\\small $t_\\textrm{Nc}$}\' center rotate by 45 front"
     -- , "set arrow from graph 0,first " ++ (show hVal) ++  " to graph 1, first "
     --      ++ (show hVal) ++ "nohead front lc rgb \"red\" lw 1  dashtype \"-\" "
      , "plot " ++ "\"" ++ dataIn ++ "\"" ++  " with lines"
     -- , "plot " ++ "\"" ++ dataIn ++ "\"" ++  " with lines"
      --, "plot " ++ "\"" ++ dataIn ++ "\"" ++  " with lines, \\"
      --,   "    (-55)+55*(1-(2.71828**(-x/5.0))) with points"      
      , "pause 0.1"
     ]
     -- set label 1 at  50, 250 '\hl{\small $t_\textrm{Nc}$}' center rotate by 45 front

Input Files ..

  • pdists02.txt .. jitter 2.0
  • pdists03.txt .. jitter 1.0
  • no file but jitter = 0.05 appeared to be a very slight non-linear distribution or just kept the original position except for the leftmost particle ???

Here's the 0.5 Jitter version .. Why the left outlier?

In [5]:
B.readFile "point_oh_five_jitter.png"

Here is jitter 1.0 version ..

In [6]:
B.readFile "one_point_oh_jitter.png"
In [7]:
rawPos <- readFile "pdists03.txt"
In [8]:
pos = map (\s -> (read s)::Float) (lines rawPos)
--putStrLn $ concatMap (\d -> show d ++ "\n") pos
In [9]:
deltas = findDeltas (take (truncate ((fromIntegral(length pos))/2.0)) pos)
vals = unlines $ map(\f -> show f) deltas
writeFile "deltas.txt" vals
In [10]:
writeFile "pos01.dat" ((concatMap (\p -> show p ++ "\n")) deltas)
runGNUPlot "pos01.dat" "Jitter 1.0 Distance Distrubution of Particles (left to right)" 
                 "Particle No. Left to Right" "Distance"  "out.png"
                 -- "Leaky Integrate and Fire Neuronal Model with Inputs"
                 --  "Time (ms)" "Activation Voltage (mV)" 
                 --      "lifwi_solution01.png" 40