leonardo
View:Recent Entries.
View:Archive.
View:Friends.
View:User Info.
View:Website (My Website).
You're looking at the latest 2 entries.

Tags:, ,
Subject:Links, Wolfram demonstrations
Time:01:58 am
FreeArc may become the next free widespread compressor:
http://sourceforge.net/projects/freearc/

Old notes regarding the iteration of collections:
http://home.pipeline.com/~hbaker1/Iterator.html

This site is growing, it shows how to solve common little programming tasks in many languages:
http://www.codecodex.com/wiki/index.php?title=Main_Page

------------------------

Mathematica is a commercial software, and its syntax is bad if you want to use it to program, but it has lot of capabilities and its visualization features are quite flexible. Lately they have added GUI widgets too, so you can use it to write little interactive applications. Here you can find almost 2300 of such tiny applications with GUI, Wolfram demonstrations project:
http://demonstrations.wolfram.com/

Among them you can learn lot of bits of basic computer science and mathematics, it's a mine. Here are some of the ones I have found more interesting:

http://demonstrations.wolfram.com/SurvivalOfTheQuasispecies/
http://demonstrations.wolfram.com/EmbryonicCleavage/
http://demonstrations.wolfram.com/IterativePolygonSimplification/
http://demonstrations.wolfram.com/OneTermNestedlyRecursiveFunctions/
http://demonstrations.wolfram.com/PassiveSonar/
http://demonstrations.wolfram.com/AreaBisectorsViaMonteCarlo/
http://demonstrations.wolfram.com/TouchingPolygonConcurrence/
http://demonstrations.wolfram.com/LocalGrowthInAnArrayOfDisks/
http://demonstrations.wolfram.com/TexturePerceptionPatterns/
http://demonstrations.wolfram.com/ImageCompressionViaTheSingularValueDecomposition/
http://demonstrations.wolfram.com/GabrielsHorn/
http://demonstrations.wolfram.com/PrimeGeneratingCellularAutomaton/
http://demonstrations.wolfram.com/CanonicalPolygons/
http://demonstrations.wolfram.com/IntrinsicallyDefinedCurves/
http://demonstrations.wolfram.com/SubstitutionSystemsInTwoDimensions/
http://demonstrations.wolfram.com/DoublingCellularAutomata/

http://demonstrations.wolfram.com/SortingNetworks/
Related:
http://blog.wolfram.com/2007/08/the_space_of_all_possible_bridge.html


Few of them have made me write similar Python code (it uses my baseconvert, to convert among different bases, and primes_list(n) that gives the first n primes):

http://demonstrations.wolfram.com/BinaryPatternsOfIntegerFunctions/
The Python code:
from baseconvert import baseconvert as bc
to2 = lambda n: bc(n, outbase=2, outdigits=" #")

from primes import primes_list as pri
for p in pri(200): print to2(p).rjust(20)
This is part of the output, you can see very nice patterns:
      # 
      ##
     # #
     ###
    # ##
    ## #
   #   #
   #  ##
   # ###
   ### #
   #####
  #  # #
  # #  #
  # # ##
  # ####
  ## # #
  ### ##
  #### #
 #    ##
 #   ###
 #  #  #
 #  ####
 # #  ##
 # ##  #
 ##    #
 ##  # #
 ##  ###
 ## # ##
 ## ## #
 ###   #
 #######
#     ##
#   #  #
#   # ##
#  # # #
#  # ###
Other patterns can be seen in the binary representation of the Fibonacci numbers:
from comb import fibonacciList as fibs
for f in fibs(100): print to2(f).rjust(70)
This is part of the output:
                 #
                # 
                ##
               # #
              #   
              ## #
             # # #
            #   # 
            ## ###
           # ##  #
          #  #    
          ### #  #
         # ####  #
        #  ##   # 
        #### ## ##
       ##   #### #
      # #    ##   
     #     # # # #
     ## #  ## ## #
    # # # ##    # 
   #   # #  # ####
   ## ########   #
  # ## # #  #     
 #  #  # #   #   #
 ### ## #   ##   #
# ######## #    # 

More patterns can be found with this simple rule, adding a number to the inverted base-2 representation of itself:
http://demonstrations.wolfram.com/ReversalAdditionSystems/
from baseconvert import baseconvert as bc
to2 = lambda n: bc(n, outbase=2, outdigits=".#")

n = 16 # 35 59 83 155
for i in xrange(35):
    print to2(n)
    n += int(bc(n, outbase=2)[::-1], 2)
This the output (if you print more lines you can see more interesting patterns, they become very cyclic later, for n = 16):
#....
#...#
#...#.
##..##
##..##.
#..##..#
#..##..#.
###..#.##
##.###..#.
#..#.#.##.#
#.#..#.#.##.
#....#####.##
#.##..##.###..
###.###.#.#..#
##....#..#.....
##...##.##...##
##...##.##...##.
#..#.#.#...#.#..#
#..#.#..#.##.#..#.
##.############.##
##.############.##.
#.#..###########...#
#..##.#########.#.##.
#.....#########.#.####
#.####..#######.###....
##..#.########.#.#.##.#
##......#.#####.#.......
##....#...###.###.....##
##....#.....#.#####...##.
#..#..#.#####.#.......#..#
#..#...##...#...###.#.#..#.
##.###...##.#.##...##.##.##
##.##.####....#.####...#.##.
#.#...#..#.##.###..#.####...#
#..##...##.#.#.#..##.#..##.##.
From such things you can see how much close are the usual cellular automata to the normal integer operations like the sum following a bit inversion...
comments: Leave a comment Add to Memories Tell a Friend

Tags:,
Subject:Pythonika V.1.0, a Mathematica - Python bridge
Time:03:25 pm
Pythonika is a very nice add-on for people that appreciate both Python and Mathematica:
http://dkbza.org/pythonika.html
It works with Python 2.4, 2.5, OSX, Win and Linux, and rather old Mathematica versions too (all binaries included too).

You can activate it inside a Mathematica notebook with just (you must have Python installed too):
Install["C:\\somepath\\Pythonika.exe"];
Then you can use Python in a very simple way, few examples:

Execute Python commands:
Py["a= 52.5+4J"]
Passing Mathematica values to Python:
ToPy["my_generic", 15+2I]
Multiline Python code:
Py["\<
square_roots = list()
for i in range(10):
    square_roots.append(i**.5)
    print square_roots[-1]
\>"]
Defining Mathematica functions in Python:
funcOne = PyFunction["def sqrt(nl): return [n**2 for n in nl]"];
Mathematica is very powerful, but I think its syntax is too much complex and bad to program. With Pythonika I can write Python scripts, and then use the wonderful plotting capabilities of Mathematica in a very quick way. A tiny example:
Install["C:\\somepath\\Pythonika.exe"];
Py["\<
from collections import defaultdict
from string import lowercase
txt = file(\"C:\\somepath\\sometext.txt\").read()
freqs = defaultdict(int)
for c in txt:
    freqs[c] += 1
freqs2 = [freqs.get(c, 0) for c in lowercase]
\>"]

ListPlot[ Py["freqs2"] ]
Output:
comments: Leave a comment Add to Memories Tell a Friend

leonardo
View:Recent Entries.
View:Archive.
View:Friends.
View:User Info.
View:Website (My Website).
You're looking at the latest 2 entries.