Time script help sought!

2005-01-11 Thread kpp9c

I am kind of in a bit of a jam  (okay a big jam) and i was hoping that
someone here could give me a quick hand. I had a few pages of time
calculations to do. So, i just started in on them typing them in my
time calculator and writing them in by hand. Now i realize, that i
really need a script to do this because:

1. It turns out there are hundreds of pages of this stuff.
2. I have to do something similar in again soon.
3. By doing it by hand i am introducing wonderful new errors!
4. It all has to be typed up anyway (which means weeks of work and even
more typos!)

The input would like so:

Item_1TAPE_1100:238:23

Item_2TAPE_128:239:41

Item_3TAPE_139:4110:41
Item_3TAPE_1410:4711:19
Item_3TAPE_1511:2111:55
Item_3TAPE_1611:5812:10
Item_3TAPE_1712:1512:45Defect in analog tape sound.
Item_3TAPE_1812:5824:20Defect in analog tape sound.

Item_4TAPE_1924:33
Item_4TAPE_11025:48
Item_4TAPE_11129:48
Item_4TAPE_11231:46
Item_4TAPE_11334:17Electronic sounds.
Item_4TAPE_11435:21
Item_4TAPE_11536:06
Item_4TAPE_11637:0137:38

These are analog tapes that were digitized (on to CD or a digital tape)
that have now been exported as individual files that are meant to be
part of an on-line audio archive. The timings refer to the time display
on the CD or digital tape. The now all have to adjusted so that each
item starts at 0.00 since they have all been edited out of their
context and are now all individual items that start at 00:00. So Item_1
which was started at 00:23 on the tape and ended at 8:23 needs to have
23 seconds subtracted to it so that it says:

Item_1TAPE_1100:0008:00

Item_2TAPE_1208:2309:41

would change to:

Item_2TAPE_1200:0001:18

etc.

but as always you may notice a wrinkle some items have many times
(here 6) indicated:

Item_3TAPE_139:4110:41
Item_3TAPE_1410:4711:19
Item_3TAPE_1511:2111:55
Item_3TAPE_1611:5812:10
Item_3TAPE_1712:1512:45Defect in analog tape sound.
Item_3TAPE_1812:5824:20Defect in analog tape sound.

This is all a single sound file and these separate times mark where
there was a break, defect, or edit in the individual item. These have
to be adjusted as well to show where these events would appear in the
new sound file which now starts at 00:00.

Item_3TAPE_1300:0001:00
Item_3TAPE_1401:0001:38
Item_3TAPE_1501:3802:14
Item_3TAPE_1602:1402:29
Item_3TAPE_1702:2903:04Defect in analog tape sound.
Item_3TAPE_1803:0414:39Defect in analog tape sound.

Further wrinkles: Some have start and end times indicated, some only
start times. I suppose that the output would ideally have both some
have comments and others don't ... and I need these comments echo-ed or
since i probably need to make a database or table eventually non
comments just have some place holder.

I'd have a lot of similar type calculations to do... I was hoping and
praying that some one here was feeling generous and show me the way and
then, of course i could modify that to do other tasks... Usually i am
happy to take the long road and all but i'll be honest, i am in a big
jam here and this huge task was just dumped on me. I am frankly a
little desperate for help on this and hoping someone is feeling up to
spoon feeding me a clear modifiable example that works. Sorry.
cheers,

kevin

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Time script help sought!

2005-01-11 Thread kpp9c
Yes, Ultimately it will be part of a large digital archive available
for researchers on site and eventually probably on-line for the New
York Public Library. It is a huge undertaking and most of the
soundfiles have been made. I (we) are struggling with the   sheer size
of the documentation Sorry about that i should have been more
clear, epecially since i am sort of begging for a little help. Sorry, i
am slightly overwhelmed at the moment...

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Time script help sought!

2005-01-11 Thread kpp9c
Thanks for this Everyone!

Trying to work with all the stuff folks are giving me on this i a have
come across a problem... down
the line i notice that some of the times will also have an hour as well
as in H:M:S (e.g. 1:22:40)

so in some cases i would need to convert H:M:S to sec and some just M:S


or should there just be a fun that passes all the times and converts
them to H:M:S first and
just appends a 00:  ((e.g. 00:02:07) if there is no hour value?
cheers,

-kp

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Time script help sought!

2005-01-11 Thread kpp9c
I also notice that there is the is the 'datetime' module, which is new
to version 2.3, which i now have access to. My feeling is that this
will do much of what i want, but i can't get my head round the standard
library reference stuff

http://www.python.org/doc/lib/module-datetime.html

I don't have any texts with me either and it probably is too new to be
in the Python Standard Library book by Fredrik Lundh or the Python
Essential Reference by  David Beazley


-kevin-

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Time script help sought!

2005-01-11 Thread kpp9c
still working on it and also fixing the input data. I think for
simplicity and consistency's sake i will have *all* time values input
and output as hh:mm:ss maybe that would be easier but i have a few
thousand find and replaceeseseses to do now (yes i am doing them by
hand)

grr... this is hard!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Time script help sought!

2005-01-11 Thread kpp9c
so all the imput will look more like this now... ( no comments either)

tem_133, DAT_20, 7, 00:58:25, 01:15:50

Item_134, DAT_20, 8, 01:15:50, 01:32:15

Item_135, DAT_21, 1, 00:01:00, 00:36:15

Item_136, DAT_60, 3, 00:18:30
Item_136, DAT_60, 4, 00:19:30
Item_136, DAT_60, 5, 00:23:00, 00:28:00

Item_137, DAT_21, 4, 00:37:00, 00:47:00

Item_139, DAT_21, 2, 00:36:15
Item_139, DAT_21, 3, 00:42:15, 01:00:50

Item_140, DAT_21, 4, 01:00:50
Item_140, DAT_21, 5, 01:25:10, 01:26:35

. snip...

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Time script help sought!

2005-01-12 Thread kpp9c
paul that is awesome so much better than what i did which was lamo
brute force method. I formmatted and reformatted my input data and
stuffed it in a HUGE dictionary it was stupid and kludgy i hope
to study all these approaches and learn something here's what i
came up with ... with my pea sized brain...

#!/usr/bin/env python

# New in version 2.3 is the 'datetime' module (see standard library
reference)
# http://www.python.org/doc/lib/module-datetime.html

import datetime

inseqs = { (1) : ['DAT_1', '01', '00:00:23', '00:08:23'],
(2) : ['DAT_1', '02', '00:08:23', '00:09:41'],
(513) : ['DAT_75', '10', '00:59:55', '01:11:05'],
(514) : ['DAT_75', '11', '01:11:05', '01:16:15'],
(515) : ['DAT_75', '12', '01:16:15', '01:34:15'],
(516) : ['DAT_75', '13', '01:34:15', '01:45:15'],
(517) : ['DAT_75', '14', '01:45:15', '01:48:00'] }


mykeys = inseqs.keys()  # first make a copy of the keys
mykeys.sort()   # now sort that copy in place

for key in mykeys:
event = inseqs[key]
print '\n','Item #', key, event
TD = datetime.timedelta
h, m, s = event[2].split(':')
zero_adjust = TD(hours=int(h), minutes=int(m),seconds=int(s))
#
print ' Q___ ', key, event[:2], ': ',
for item in event[2:]:
hrs, mins, secs, = item.split(':')
time1 = TD(hours=int(hrs), minutes=int(mins),seconds=int(secs))
print time1 - zero_adjust,

print

-- 
http://mail.python.org/mailman/listinfo/python-list


permutations, patterns, and probability

2005-02-01 Thread kpp9c
Greetings,

I am working on a program to produce patterns. What would like is for
it to  exhaustively produce all possible permutations of a sequence of
items but for each permutation produce variations, and also a sort of
stutter based on probability / weighted randomess.

Let us say we have tiles of four primary colors: ['Red', 'Blue',
'Green', 'Yellow']. Now we also have 4 alternatives or substitutes for
each color ['Maroon', 'Navy_Blue', 'Forest_Green', 'Dark_Brown']

We pick a unique permutation, say: ['Red', 'Blue', 'Yellow', 'Green']

Now I would like to pick the primary colors substitute (say 30% chance
for each element) so instead of our plain

['Red', 'Blue', 'Yellow', 'Green']

we might end up with:

['Red', 'Navy_Blue', 'Yellow', 'Forest_Green']

or

['Maroon', 'Navy_Blue', 'Yellow', 'Green']

Whatever... The main point is that sometimes the original color is
retained and sometimes the dark color is substituted.

Now I want to take this list and sometimes stutter an element so that
there is, let us say a 50% chance for each element, that it is
stuttered, and it may be repeated 1 (34%), 2(66%), or 3(33%) times. So
that we could get:

['Maroon','Maroon','Navy_Blue', 'Yellow','Yellow','Yellow','Yellow',
'Green']

The program would quit when all 24 (in the case of 4 elements) was
exhausted.

I have code that makes weighted randomness. I have code that makes
permutations, but I am having trouble putting this all together...
While i work on it though that i might ask for help... I'd like for the
code to be reusable and am building a library of functions for
patterns.

cheers,
kevin


### This is not mine, it is from a python book... I believe the Lutz
book

def permute(list):
if not list:# shuffle any
sequence
return [list]   # empty
sequence
else:
res = []
for i in range(len(list)):
rest = list[:i] + list[i+1:]# delete
current node
for x in permute(rest): # permute the
others
res.append(list[i:i+1] + x) # add node at
front
return res

mport random

### This this is mine, but seems to work anyway hee hee

def windex(lst):
'''an attempt to make a random.choose() function that makes
weighted choices

accepts a list of tuples with the item and probability as a
pair
like: >>> x = [('one', 0.25), ('two', 0.25), ('three', 0.5)]
>>> y=windex(x)'''
n = random.uniform(0, 1)
for item, weight in lst:
if n < weight:
break
n = n - weight
return item

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: random playing soundfiles according to rating.

2006-02-09 Thread kpp9c
I've been looking at some of the suggested approaches and looked a
little at Michael's bit which works well bisect is a module i
always struggle with (hee hee)

I am intrigued by Ben's solution and Ben's distilled my problem quite
nicely, but, welli don't understand what "point" is doing with
wieght for key, weight for zlist, furthermore, it barfs in my
interpreter... (Python 2.3)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Scientific Computing with NumPy

2006-02-17 Thread kpp9c
Numeric, Numarray, & Numpy... some one stick a screwdriver in my
forehead and end the madness that Numeric has become.

Brilliant programming & an almost essential part of scientific & math
hacking in python made maddeningly confusing by truly dumb naming
scheme.

For crying all night! Numpy was Numeric's nickname!!... choose a new,
related, but unique name Holy cow!!! How hard is that? A group of
folks smart enough to come up with such an amazing piece of software
can't do better than to avoid this unnecessary confusion?

only Apple could top naming as retarded as this.

with 2.3 seconds i came up with this:

Nappy

Numeric Array processing in Python

similar enough to suggest its origins, unique enough to not confuse the
heck out of everyone...

I am sure folks can do better, but really!



-- 
http://mail.python.org/mailman/listinfo/python-list


ls files --> list packer

2006-02-23 Thread kpp9c
I would like to use the power of Python to build some list structures
for me.

Namely i have organized a bunch of folders that have soundfiles in them
and would like Python to slurp up all the .aif/.aiff (or .wav whatever)
files in a given set of directories. My friend hacked up this is perl:

$files = `ls /snd/Public/*.aiff`;

@snd_filelist = split('\n',$files);

$i = 0;
while ($file = @snd_filelist[$i]) {
   print "file $i = @snd_filelist[$i]\n";
   $i++;
}


The only catch with the above code (besides its hideousness hee hee) is
if you have a directory w/i the structure, but in general it works and
with this i can just put gobs of files into separate dirs pack them
into a list and then send them to my script that scrambles them and
plays them.

I would like something similar, that works with python that is more
elegant and maybe even more robust.

but i am failing miserably and my perl friends mock me.

cheers,
kp8

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ls files --> list packer

2006-02-23 Thread kpp9c
and one example of a slightly fancier version would be a variation that
looks recursively into subdirectories and makes separate lists for each
subdirectory encountered.

so if i had a directory called "~/snd/"

and in "~/snd/" i had:

"~/snd/one/"
"~/snd/two/"
"~/snd/three/"

each with soundfiles in it.

I could get those packed in three separate lists named after the
directory or some such thing

This would be so awesome because my carefully organizing your
directory, you would be carefully
organizing your data, change your dir structure or add/delete some
files and you would get a new structure in your script... prolly would
work with scripting your iTunes music folder too...

gosh ... sorry ... just thinking out-loud here and getting kind of
giddy! reaching for the python book ...

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ls files --> list packer

2006-02-24 Thread kpp9c
cool i just tried:

>>> import os
>>>snd_filelist = [f for f in os.listdir('/Users/foo/snd') if 
>>>f.endswith('.aif')]


and it worked! and will take a huge bite out of my big script ... which
i make by doing an ls
in the terminal and editing (boo hoo)

one one lc and one import!

cool..

that other sillyness i mentioned is not strickly required  ... just
dreaming but i know involves some kind of os walk type thing prolly ...
meanwhile this is so exciting!

Thank you

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ls files --> list packer

2006-02-24 Thread kpp9c
gosh i could even use other string methods like startswith to take all
the files in a given directory which i have organized with a prefix and
have them stuffed in different lists  ... i think ...

snd_filelist = [f for f in os.listdir('/Users/foo/snd') if
f.endswith('.aif') & f.startswith('r')]

\m/ (>.<) \m/

yeah!

runnin' to the interpreta now...

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ls files --> list packer

2006-02-24 Thread kpp9c
that is nice but the little further wrinkle, which i have no idea
how to do, would be to have the contents of each directory packed into
a different list since you have no idea before hand how many lists
you will need (how many subdirs you will enounter)  ... well that is
where the hairy part comes in...

-kp--

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ls files --> list packer

2006-02-26 Thread kpp9c
os.listdir works great ... just one problem, it packs the filenames
only into a list... i need the full path and seach as i might i se NO
documentation on python.org for os.listdir()

how do i either grab the full path or append it later ...

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ls files --> list packer

2006-02-26 Thread kpp9c
Thank you... i was looking in the wrong place cause all i found was
this relatively useless doc:

http://docs.python.org/lib/module-os.html

which says almost nothing.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ls files --> list packer

2006-02-27 Thread kpp9c
nice! two little lines that do a boatload of work! hee hee


pth = '/Users/kpp9c/snd/01'
samples = [os.path.join(pth, f) for f in os.listdir(pth) if
f.endswith('.aif')]


thank you Kent! (and Jeremy and Magnus and Singletoned and I V ... and
john boy and mary ellen .. )

-- 
http://mail.python.org/mailman/listinfo/python-list


time conversions [hh:mm:ss.ms <-> sec(.ms)

2006-04-28 Thread kpp9c
Hi,

I was looking at python & datetime and hoping that it would already
have
a method/func to translate time formats. I need to translate seconds to
hh:mm:ss.ms and vice versa and would like the ability to do some basic
arithmetic in these formats. I think that there just has to be a
package
or module out there that already does this with reasonable speed and
accuracy.

Sadly, i do indeed need both reasonable speed and accuracy since i will
be adding up huge masses of small events (around 10 to 60 ms
milliseconds
in length) to create cloud like textures for real time audio/video at
high sampling rates.

i googled for hh:mm:ss.ms + python and didn't find much...

best,

-kp---

[mac os x w/ python 2.4.1]

-- 
http://mail.python.org/mailman/listinfo/python-list


resume picking items from a previous list

2006-04-29 Thread kpp9c
I have a several list of songs that i pick from, lets, say that there
are 10 songs in each list and there are 2 lists.

For a time i pick from my songs, but i only play a few of the songs in
that list... now my wife, Jessica Alba, comes home, and i start playing
from Jessica's list of songs. After playing a few songs, Jessica, who
needs her beauty sleep, goes to bed, and i start my play loop which
starts picking from my songs again...

The wrinkle:
only now i want it to pick first from among the 6 songs yet not played
from the first time around, and *then* when the list is exhausted,
shuffle the whole original list of songs and start again.

Here is some working but hilariously bad code that does most of this
funny biz... I've gotten this far, but can't figure out how to get the
loops to keep track of what was played and what wasn't and how to
pick-up the list where it left off.

I know this is a dumb thing to want to do, but you know, being married
to bona-fide star is not easy.

# ---
#!/usr/bin/env python

import random
import os

def shuffleloop(iterable):
"""An iterator like itertools cycle, which returns elements from the
iterable and saves a copy of each. When the iterable is
exhausted, it return elements from the saved copy.

The added wrinkle here is that the saved copy is randomly shuffled.
Repeats indefinitely."""
saved = []
for element in iterable:
yield element
saved.append(element)
while saved:
random.shuffle(saved)
for element in saved:
yield element

def playall_reload(startime, playdur, smpl_lst):
'''a loop that shuffles and plays all sounds in a list. If the
sequence is exhausted the list is reloaded, re-shuffled, and plyed
through
again. It does this as many times as needed to fill the time
specified.

Also returns the end of the last duration so that the begining of the
next
section can be fed to the next function or loop.
'''
event = 0; incr = 0; lst_len = len(smpl_lst)
random.shuffle(smpl_lst)
smpl_loop = shuffleloop(smpl_lst)
endpoint = startime + playdur
while startime < endpoint:
sample = smpl_loop.next()
splt = os.path.split(sample)
# get the duration of the current soundfile
# (hard wire it for now)
#incr = DUR()
dur = 10
#load the sample & play it
#
# input(sample)
# PLAY(startime, dur)
#
print "event %d @ %.4f  --> [%s] dur: %.4f" % (event+1, 
startime,
splt[1], dur)
incr = dur
startime = startime + incr
event = event + 1
if (event < lst_len):
print "\n\n*** Heads-up yo: 
***\n\n"
return startime


def test():
kevins = ['/Users/kevin/snd/songs/loveisintheair.aif',
'/Users/kevin/snd/songs/boymeetsgirl.aif',
'/Users/kevin/snd/songs/yourcheatingheart.aif',
'/Users/kevin/snd/songs/kindletheflame.aif',
'/Users/kevin/snd/songs/mywifeissohot.aif',
'/Users/kevin/snd/songs/haha.aif',
'/Users/kevin/snd/songs/blueberryorstrawberry.aif',
'/Users/kevin/snd/songs/didyoupaytheelectricbill.aif',
'/Users/kevin/snd/songs/whereistheremote.aif',
'/Users/kevin/snd/songs/youspenthowmuchforthoseshoes.aif']

jessicas = ['/Users/kevin/snd/quiet_songs/iloveu.aif',
'/Users/kevin/snd/quiet_songs/uloveme.aif',
'/Users/kevin/snd/quiet_songs/wearehappy.aif',
'/Users/kevin/snd/quiet_songs/wearesad.aif',
'/Users/kevin/snd/quiet_songs/letsbreakup.aif',
'/Users/kevin/snd/quiet_songs/letsgetbacktogether.aif',
'/Users/kevin/snd/quiet_songs/walkinthesunshine.aif',
'/Users/kevin/snd/quiet_songs/iloveutruly.aif',
'/Users/kevin/snd/quiet_songs/whosefootisthat.aif',
'/Users/kevin/snd/quiet_songs/ohbaby.aif']

print
one = playall_reload(1.00, 20.00, kevins)
print
two = playall_reload(one, 180, jessicas)
print
three = playall_reload(two, 40.00, kevins)

if __name__ == '__main__':
test()

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: time conversions [hh:mm:ss.ms <-> sec(.ms)

2006-04-29 Thread kpp9c
timedelta looks to be just the ticket! bravo, thank you... i guess this
must be pretty new to Python. Nice... more "batteries included"
stuff...

cheers,

-kevin--

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: midi input

2006-04-29 Thread kpp9c
http://www.mxm.dk/products/public/pythonmidi

mxm rocks!

i used to use it this to create midi files so i know it works... but
now it has grown to big for my small brain, & have no clue how to
actually use it... i keep hoping for a small tutorial and some more
docs, this partially due to the bizarre mysteries and dark science
of the midi file format and how it actually works with time. I would
love to be able to use this again... I just need to figure out how to
change real human time into something that midi can use.

If i could specify a tempo base (tempo of say 60)
and have it go up a scale in quarter notes or something.. i could maybe
figure it out from there. I just want to be able to specify notes like
csound or something does:

start_time, duration, freq

etc

but i think that this also will do realtime stuff and you can
monitor/filter/pipe incoming midi data as well. I just don't know how
to do that either

another possibility is to look at csound
or cmix
or pd
or supercollider


all of which are free, mostly open source, and available on linux

good luck on your quest!

-- 
http://mail.python.org/mailman/listinfo/python-list


Python Launcher.app on OS X

2009-02-09 Thread kpp9c
I am very confused about the current state of Python on OS X 10.5.
Looks like Apple ships with 2.5.1 and that is also the latest
installer for OS 10.5. The notes on the wiki page found here:

http://wiki.python.org/moin/MacPython/Leopard

Say:

Mac OS X 10.5.x (Leopard) comes with the 2.5.1 Python distribution pre-
installed, with an integrated Python Launcher.app

[...]

It is recommended that you delete the newly installed Python
Launcher.app, because it is already present inside the system
Python.framework. If you have installed Apple's developer tools (Xcode
et al), it is recommended that you delete the newly installed Build
Applet.app, because it is already present in /Developer/Applications/
Utilities/MacPython 2.5.

okay... for the life of me i do not see any Python Launcher.app and i
just installed OS X 10.5 (running 10.5.6 on intel)  and i also
installed the dev kit.

Where the heck is this application?

best,

kp


--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Launcher.app on OS X

2009-02-10 Thread kpp9c
So how does this effect the install instructions found on the link:

http://wiki.python.org/moin/MacPython/Leopard

do you trash that when you do an install on OS X? I am so hesitant to
delete anything that resides in /System



--
http://mail.python.org/mailman/listinfo/python-list


markov query

2006-03-13 Thread kpp9c
markov query

I have noticed a couple markov implementations in python, but none
quite seem to do what i would like. Most seem to do an analysis of some
text and create a new text based on that... I think, (sorry i just
don't know terminology well) a markov table (or is it called a
transition table) to describe how to get from one event to another.  So
if i have 3 events, say,  A, B, and C which can come in any order, a
Markov chain describes the probability of what the next event will be
using a table. The following table demonstrates a first-order Markov
chain. There are three possible states. Either the current event is A,
B, or C. For each possible current state, there are three possible next
letters. Each row in the table indicates the relative probability of
going to the next letter. For example, if you are currently on letter
A, there is a 20% chance of repeating letter A, a 50% chance of going
to B, and a 30% chance of going to C. Note that the sum of changes for
each row is 100% (20 + 50 + 30 = 100).

Current -- next -- next -- next
A - B - C
  A:20% -- 50% -- 30%
  B:35% -- 25% -- 40%
  C:70% -- 14% -- 16%

Here the sequence C B and C C would be rare and the sequence C A
common.

This is a first-order Markov chain, which means that only the current
state affects the choice of the next event. A second-order Markov chain
would mean that the current state and the last state affect the choice
of the next event. A third-order Markov chain would indicate that the
current state and the last two states in the sequence will affect the
choice of the next state, and so on. Here is an example transition
table for a 2nd order Markov chain.

Current -- next -- next -- next
A - B - C
  A A  15% 55% 30%
  A B  20% 45% 35%
  A C  60% 30% 10%
  B A  35% 25% 40%
  B B  49% 48% 3%
  B C  60% 20% 20%
  C A  5%  75% 20%
  C B  0%  90% 10%
  C C  70% 14% 16%

For example, if the current event is B and the last one was A, then the
probability of the next event being A is 20%, B is 45% and C is 35%.
The pattern C B A will never occur, and the pattern B B C will occur
rarely.

Does anyone know of any modules or packages that include markov tables
for creating patterns like shown above.


P.S. Does any one know first of all whether these are called markov
tables, transition tables or probability tables? I am not sure i am
referring to this correctly and what the differences would be if any

cheers,

kp

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: markov query

2006-03-14 Thread kpp9c
> Yes, a system which does this has to build a Markov chain from a data
> set and then traverse it.

>Any program that actually uses Markov chains to generate new text based
>on existing input as you've described will necessarily create a Markov
>chain.

I think you misunderstood. If you see my original post my whole point
was that this was exactly what i don't want. There are several
algorithms out that that already do that. I want to use a table that i
define from scratch to shape a stochastic process. In this case there
is no original input to analyze and i don't want a chain built by
analysis and i am not using necessarily texts.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: markov query

2006-03-14 Thread kpp9c
>Yes, a system which does this has to build a Markov
>chain from a data set and then traverse it.

>>Any program that actually uses Markov chains to generate
>> new text based on existing input as you've described

Hi. That isn't really what i have described. If i did i could use
exsisting algorithms. What you describe is exactly what i don't want in
this particular case. I am actually not wanting it to build a chain
from some input that it analyzes. There is no input. If you see, i am
trying to define a table that tells it how to proceed forward from
scratch as a stochastic process.

cheers,

-kp--

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FIR filtering

2006-03-15 Thread kpp9c
www.rtcmix.org

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Markov process representation

2006-03-15 Thread kpp9c
This is wicked! I am trying to get it to work and am frantically fixing
tabs and spaces... but isn't line 50:

self._all_states |= set(key[i] for key in probabilities)

an error? isn't it supposed to be:

self._all_states != set(key[i] for key in probabilities)

-- 
http://mail.python.org/mailman/listinfo/python-list


pretty print, tidy, reindent.py

2006-03-15 Thread kpp9c
What ever happened to reindent.py ? This used to be part of the
distribution. Does it still work with modern versions of python?

A lot of the code i drag off here (even if i use "show original"!)
comes out all messed up and i end up having to clean a lot of it up. I
wonder if there is a reformatter/pretty printer that like perl tidy
that might help. I see i have tabnanny, but that only complains... i
want something that fixes automagically.

-kp8--

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Markov process representation

2006-03-15 Thread kpp9c
try as i might i still get an error:

  File "markov.py", line 50
self._all_states |= set(key[i] for key in probabilities)


I am running:

Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin

If that helps any...

Thanks!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Markov process representation

2006-03-15 Thread kpp9c
yes looking at this code i see a few things i haven't seem before. I am
on Mac OS X 10.3.x and updating the python seems like a non trivial
task at the moment.. i will try that and see where that gets me. Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Markov process representation

2006-03-15 Thread kpp9c
oh ... uhmm .. i don't follow what you are saying... where should i put
those lines... should the import thing go on top?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Markov process representation

2006-03-15 Thread kpp9c
hee hee  works fine ... but kinda slow on my old machine... really
time for a new laptop haha!

still this code is so beautiful! *^-^*

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pretty print, tidy, reindent.py

2006-03-15 Thread kpp9c
thanks. i didn't realize just how bare bones that mac os x install of
python is. I just grabbed it from the source.

cheers,

-kp-

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there no end to Python?

2006-03-18 Thread kpp9c
>>  This is good thing because I can ignore what I don't need.

I am finding that this is really not true for me. I find that if i use
other folks code, collaborate, or get help from other folks i still
have to know all the new constructs that i don't often use, and i
really struggle with iterators and generators and some of the newer
things and folks seem to have fallen in love with ridiculously complex
list comprehensions. (i'll admit i love the list comprehensions too,
but too a point)

Don't get me wrong, i LOVE Python, but since 2.2 or so the language has
started to get some feature creep and is starting to evolve
exponentially fast and while all that pre 2.2 code is really readable
still, i see some stuff now that really really hurts my brain. We see
less silly lambdas than we used to, and Python is more powerful than
ever, but i think there has been a cost too. Python has become harder
to read and *MUCH* harder to learn all of a sudden.

Personally i would like to see the core Python language evolve more
slowly and see work on packages, modules and DOCS!!

but i am sure that is very much a minority opinion. I found the
language additions of 2.3 and 2.4 really hard to absorb.

flame away... 

-kp--

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there no end to Python?

2006-03-18 Thread kpp9c
>> This is a common (and silly) whine.

1. not a whine
2. if it is really common is it all that silly?

>> effort in a free system is not
fungible.  The odds of your affecting how the people doing the work
by complaining about how they do it and their priorities are about
zero to one.


That is true only if my goals were to actually effect a change. if you
read what i wrote it is 1000% clear i don't expect that at all. Just
stating an opinion about how Python has evolved. We've seen a lot of
gains, in terms of power and speed and have lots of new toys, i am just
point out that any new tech comes at a cost, and that this whole "i
don't need to know this thing that has fundamentally changed how the
program works" idea is a flawed. It don't matter that you don't use it,
at some point someone else will and unless you live in a cave, you are
gonna be staring at other folks code scratching your head. I am a
better programmer than before, but i scratch my head a lot more @ 2.4
that i did at 2.0.

oh, well. i knew some one would flame me.

-kp8--

my main point is that new language constructs giveth and new language
constructs also taketh away.

-- 
http://mail.python.org/mailman/listinfo/python-list


overlapping sets

2006-03-23 Thread kpp9c
I have a question... and ... whew ... i am gonna be honest, i haven't
the slightest clue how to even start ... i am not sure if i used up all
my good will here or can take a mulligan.. i love to try to at least
post some lame broken code of my own at first... but like i said, not
being a math person i am not even sure how to start or if it is even
possible.

here's the deal... i have a dictionary that defines some collections..
like so:

sets = { ('one') : [0, 4, 7, 9 ],
('two') : [0, 3, 7, 9 ],
('three') : [0, 4, 7, 11],
('four') : [0, 3, 7, 10 ],
('five') : [0, 4, 7, 10 ],
('six') : [0, 4, 8, 10 ],
('seven') : [0, 3, 6, 10],
('eight') : [0, 3, 6, 9 ],
('nine') : [0, 3, 7, 11 ],
('ten') : [0, 5, 7, 10 ] }

I every time i call this function i would like like it to return a
collection at random, any collection, so long as it has all but one
element that is the same. So if i grab [0, 4, 7, 9 ] as my first set
my next set could be: [0, 3, 7, 9 ], or [0, 4, 8, 9 ], or [0, 4, 7,
10], or [1, 4, 7, 9 ], since all these sets contain 3 elements in
common with the first, and only one that is new or different... but if
my first run give me: [0, 4, 7, 9 ] i would not get [0, 5, 7, 10 ],
since this is set has 2 elements that are unique. The goal it to move
from set to set to set to set always with a maximum of overlap & common
elements.

I wonder, if this is even possible, *and* if it can be done with sets
that have as many as 7, 8, or even 9 elements or if this would be too
slow to even attempt.

cheers,

kp8

[for the record using python 2.3 on a macintosh at the moment]

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Remove integer from float number

2006-03-23 Thread kpp9c
okay... out of curiousity... how would you then seperate the interger
value from the fractional part do something to one side and then put it
back together... like if you had 8.01 and you want to add to the '8'
part in one way (ordinary decimal) and add to the .01 part modulo
something .. like say modulo 12 so that adding .11 to 8.01 would give
you 9.0 ...

so that you had something like:

 . . . 7.11, 8.00, 8.01, 8.02, 8.03, 8.04, 8.05. 8.06, 8.07, 8.08,
8.09, 8.10, 8.11, 9.00 ...

why you might ask? This is one way that computer's can understand
musical pitch... the '.xx' part represents
the pitch classes (chromatically c-b) and the integer portion
represents the octave... go from b 7.11 to c (7.12 = 8.0)
and likewise down from c (6.00 for example) to b 5.11 ...

sometimes you want to 'pop' off the pitch-class portion of the number
and do things but also keep track
of your octave crossings

sometimes you think "why would anyone want to do that" so here is why i
could use such a thing..
you have sort of compound notation that has to account for the base 12
part of the problem and
our octaves in regular base 10...

hehe...

sorry iffin i am highjacking the thread ..

-k

-- 
http://mail.python.org/mailman/listinfo/python-list


Very simple finite automaton (?)

2009-09-22 Thread kpp9c
Very simple finite automaton (?)

I am not sure if this is and example of Finite Automaton or a Finite
State Machine or perhaps it is related to a transition table or markov
process. I am not a math person so i am not sure what it is called. I
googled around and got lots of super complicated gobbledegoo all with
knotty regex stuff, but what i want to do is much more simple.

I am trying to use a table (called a transition table? i dunno) to
define a bunch of moves like so:

1 --> 2 5
2 --> 1 4
3 --> 3
4 --> 1
5 --> 4 3

so that i can generate a sequence that, given an initial value, will
continue to grow according to these rules.

So starting with 1, we get:

1
2 5
1 4 4 3
2 5 1 1 3
1 4 4 3 2 5 2 5 3


. etc.

Essentially, iterating over the last added items to the list, applying
the table, adding those new items to the list, applying the table
again... etc, until the sequence reaches some predetermined number of
iterations and quits.


[ [1], [2, 5], [1, 4] , [4, 3], [2, 5], [1], [1], [3], [1, 4], [4, 3],
[2, 5], [2, 5], [3] ]


First, I would like to know what, precisely, this kind of process is
called so that i can look it up. Many names are suggested but when
googling more names and acronyms show up, maybe there are many names
used for a variety of related things, but I could be curious to know
exactly what this is an instance of. Second, I am not sure how to get
started with the loop (is this an example of recursion?) and how best
to represent the table (dictionary)? If anyone has an example of how
to do this or a suggestion on where to start poking around, that would
be great.

cheers,

kp

macosx, python2.5 & 2.6

-- 
http://mail.python.org/mailman/listinfo/python-list