Skip to main content
Code Review

Return to Question

added 14 characters in body
Source Link

The Python script takes an initial subseta list as an input (startingSet) and compares it to all equal-length combinations of the members of the parent set (harmPool). The absolute-value difference between the given set and the equivalent member of the compared set is found, and these differences are summed to create what I’m calling the "parsimony ranking" (PR) of that chord movement. (The PR is a completely arbitrary number that serves to rank all possible combinations of the parent set according to their distance from the starting set.)

The Python script takes an initial subset as an input and compares it to all equal-length combinations of the members of the parent set. The absolute-value difference between the given set and the equivalent member of the compared set is found, and these differences are summed to create what I’m calling the "parsimony ranking" (PR) of that chord movement. (The PR is a completely arbitrary number that serves to rank all possible combinations of the parent set according to their distance from the starting set.)

The Python script takes a list as an input (startingSet) and compares it to all equal-length combinations of the members of the parent set (harmPool). The absolute-value difference between the given set and the equivalent member of the compared set is found, and these differences are summed to create what I’m calling the "parsimony ranking" (PR) of that chord movement. (The PR is a completely arbitrary number that serves to rank all possible combinations of the parent set according to their distance from the starting set.)

added 1578 characters in body
Source Link

TheThis program takes a very long time to do each and every step, even the very first print statement. Why is this, and what is the best way to diagnosing a problem like this in any language?

Also, I'd appreciate it if you could harshly critique my code and style so I can make it better/more Pythonic.

Description

The Python script takes an initial subset as an input and compares it to all equal-length combinations of the members of the parent set. The absolute-value difference between the given set and the equivalent member of the compared set is found, and these differences are summed to create what I’m calling the "parsimony ranking" (PR) of that chord movement. (The PR is a completely arbitrary number that serves to rank all possible combinations of the parent set according to their distance from the starting set.)

For example if the initial set is [a, b, c, d] and the combination set is [e, f, g, h], the PR would be found via

[( | a -/+ e | ) + ( | b -/+ f | ) + ( | c –/+ g | ) + ( | d -/+ h | )].

If the initial set is [50, 55, 60, 64] and the combination set is [50, 52, 60, 65.86], the parsimony ranking (at least in this initial statement of the problem) would be 4.86 (since ( | 55 – 52 | ) + ( | 64 – 65.86 | ) = 4.86 and the two values are shared by the sets.

The Python program works by simply generating a list of sets whose PR is below a specified threshold. One set is then selected from this list using a probability distribution that favors positive numbers close to zero. (An exponential distribution might work well, although the example code uses a triangular distribution with a low mode value.) Once a set is selected from the available options, this set becomes the starting set and the process for deriving the next chord will start all over again. The process repeats until a specified number of chords are generated.

The program takes a very long time to do each and every step, even the very first print statement. Why is this, and what is the best way to diagnosing a problem like this in any language?

Also, I'd appreciate it if you could harshly critique my code and style so I can make it better/more Pythonic.

This program takes a very long time to do each and every step, even the very first print statement. Why is this, and what is the best way to diagnosing a problem like this in any language?

Also, I'd appreciate it if you could harshly critique my code and style so I can make it better/more Pythonic.

Description

The Python script takes an initial subset as an input and compares it to all equal-length combinations of the members of the parent set. The absolute-value difference between the given set and the equivalent member of the compared set is found, and these differences are summed to create what I’m calling the "parsimony ranking" (PR) of that chord movement. (The PR is a completely arbitrary number that serves to rank all possible combinations of the parent set according to their distance from the starting set.)

For example if the initial set is [a, b, c, d] and the combination set is [e, f, g, h], the PR would be found via

[( | a -/+ e | ) + ( | b -/+ f | ) + ( | c –/+ g | ) + ( | d -/+ h | )].

If the initial set is [50, 55, 60, 64] and the combination set is [50, 52, 60, 65.86], the parsimony ranking (at least in this initial statement of the problem) would be 4.86 (since ( | 55 – 52 | ) + ( | 64 – 65.86 | ) = 4.86 and the two values are shared by the sets.

The Python program works by simply generating a list of sets whose PR is below a specified threshold. One set is then selected from this list using a probability distribution that favors positive numbers close to zero. (An exponential distribution might work well, although the example code uses a triangular distribution with a low mode value.) Once a set is selected from the available options, this set becomes the starting set and the process for deriving the next chord will start all over again. The process repeats until a specified number of chords are generated.

deleted 196 characters in body
Source Link

As a new Python programmer (and very new, self-taught programmer in any language), I've finally managed to write my very first program that does something usefully for me!

The only problem is, the program takes a very long time to do each and every step, even the very first print statement. Why is this, and what is the best way to diagnosing a problem like this in any language?

As a new Python programmer (and very new, self-taught programmer in any language), I've finally managed to write my very first program that does something usefully for me!

The only problem is, the program takes a very long time to do each and every step, even the very first print statement. Why is this, and what is the best way to diagnosing a problem like this in any language?

The program takes a very long time to do each and every step, even the very first print statement. Why is this, and what is the best way to diagnosing a problem like this in any language?

deleted 92 characters in body; edited tags
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
Loading
Changed title
Link
Phrancis
  • 20.5k
  • 6
  • 69
  • 155
Loading
Source Link
Loading
lang-py

AltStyle によって変換されたページ (->オリジナル) /