back to list

Bayesian tuning

🔗Daniel Nielsen <nielsed@...>

4/24/2011 10:02:48 PM

This is a set of tunings based on the Bayes formula.

How it is generated:
It assumes a binary Bayes process (i.e. two exhaustive, mutually exclusive
possible outcomes) with an initial prior probability for "success" of 1/2.
From there, a likelihood ratio is found that causes the value after N
iterative evaluations to fall on the 2/1 octave. (N, therefore, is the
number of pitches in the octave, since the value at each iteration
represents a pitch.)

Here are results for N=9, as an example:
0.0000
-108.8867
-224.1946
-345.8528
-473.7450
-607.7137
-747.5635
-893.0673
-1043.9709
-1200.0000

Why are these negative? Well, I wasn't certain whether to add another octave
or to invert the values to make a tuning. What's interesting is that, if we
invert the likelihood ratio that defines this set, we get a 3/2 range in the
opposite direction instead. Values are the following (again using the
example of N=9):
0.0000
102.4416
198.4620
288.1322
371.5683
448.9280
520.4065
586.2311
646.6557
701.9550

Below you'll find a hacked-together BASIC program to generate values for
different N. This program can also generate another set of related values
which I'll describe briefly now:

The 2-variable generating function for the poly-Bernoulli numbers of
negative index (first presented in 1999 by Kaneko and called "the symmetric
formula" in related papers) is simply a form of the Bayes formula times a
likelihood ratio (the inverse likelihood ratio of what is commonly used by
statisticians). I'm not certain whether or not this has been noted
explicitly, but I haven't seen any mention of the fact in Kaneko's papers or
other related writings that I've read. The fact might be picked up on by
those who investigate neural networks, since such a form is very important
in that field. Anyway, replacing that likelihood ratio with the inverse of
that gives the generating function for the alternating poly-Bernoulli
numbers of negative index. Such properties also directly extend to the
multi-poly-Bernoulli numbers, but this gets off-track.

I made proofs for the above facts about 3/2 yrs ago; if interested, more
detail may be provided.

Here's the program; I'll also put a compiled version in my folder. It
outputs to OUT.TXT in the directory it is run in.
___________________________

'BAYESTUN.BAS
'Dan Nielsen

DECLARE FUNCTION eq# (a AS DOUBLE, b AS DOUBLE)

CONST N = 9 'Number of pitches in list minus 1

'Choose one of the following
CONST a = 0 'Bayes formula
'CONST a = -1 'Kaneko symmetric formula

DEFDBL A-Z
CLS
OPEN "out.txt" FOR OUTPUT AS #1

'Find k
k = 0 'Initial guess for k
delta = .1 'Initial correction change increment
dir = 0 'Last correction direction (1 for add; -1 for subtract)
kloop:
x = .5 'Initial prior probability
y = EXP(k) 'Likelihood ratio (inverse of common convention)
FOR i = 1 TO N
IF a THEN b = y ELSE b = 1
x = (b * x) / (x + y - x * y)
z = (1200 * LOG(x) / LOG(2)) + 1200
NEXT
IF NOT eq(ABS(z), 1200) THEN
IF ABS(z) < 1200 THEN
k = k + delta
IF dir <> 1 THEN delta = .5 * delta
dir = 1
END IF
IF ABS(z) > 1200 THEN
k = k - delta
IF dir <> -1 THEN delta = .5 * delta
dir = -1
END IF
GOTO kloop
END IF

PRINT #1, " k ="; k
PRINT " k ="; k

FOR j = 1 TO -1 STEP -2 'Inverts likelihood ratio on second iteration

x = .5 'Initial prior probability
y = EXP(j * k) 'Likelihood ratio (inverse of common convention)
z = (1200 * LOG(x) / LOG(2)) + 1200

PRINT #1, " "; : PRINT #1, USING "#####.####"; z
PRINT " "; : PRINT USING "#####.####"; z

FOR i = 1 TO N

IF a THEN b = y ELSE b = 1
x = (b * x) / (x + y - x * y)
z = (1200 * LOG(x) / LOG(2)) + 1200

PRINT #1, " "; : PRINT #1, USING "#####.####"; z
PRINT " "; : PRINT USING "#####.####"; z

NEXT

PRINT #1, "--------------"
PRINT "--------------"
SLEEP

NEXT

CLOSE

FUNCTION eq (a AS DOUBLE, b AS DOUBLE)
IF (ABS(a - b) < .000001) THEN eq = -1 ELSE eq = 0
END FUNCTION

🔗Mike Battaglia <battaglia01@...>

4/24/2011 10:50:35 PM

On Mon, Apr 25, 2011 at 1:02 AM, Daniel Nielsen <nielsed@...> wrote:
>
> This is a set of tunings based on the Bayes formula.
> How it is generated:
> It assumes a binary Bayes process (i.e. two exhaustive, mutually exclusive possible outcomes) with an initial prior probability for "success" of 1/2. From there, a likelihood ratio is found that causes the value after N iterative evaluations to fall on the 2/1 octave. (N, therefore, is the number of pitches in the octave, since the value at each iteration represents a pitch.)

Hi Dan,

For the record, you might find a better response if you start posting
stuff like this to tuning-math:

/tuning-math/

But I'm not sure I understand exactly what you're doing here - would
you mind spelling it out for me a bit? It looks fascinating, but I
admit that I'm completely lost.

-Mike

🔗Daniel Nielsen <nielsed@...>

4/24/2011 11:50:59 PM

>
> Hi Dan,
>
> For the record, you might find a better response if you start posting
> stuff like this to tuning-math:
>
> /tuning-math/
>
> But I'm not sure I understand exactly what you're doing here - would
> you mind spelling it out for me a bit? It looks fascinating, but I
> admit that I'm completely lost.
>
> -Mike
>

Thanks for the response, Mike. Honestly I'm terrified of tuning-math since I
have a hard enough time understanding what's going on here, but since these
sorts of things do fall into the more general realm than the mainstays of
contemporary tuning theory, I probably should register over there, if that'd
be okay.

I'll start by describing my motivation for something like this as best I can
piece it together. The Bayes formula at its most simple root is just
probabilistic multiplication:
P(S and R) = P(S|R) P(R) = P(R|S) P(S)
where P(R|S) means "probability of condition R is true given condition S is
true"; therefore
P(R|S) = P(S|R) P(R) / P(S)
Now, from that point, folks go in LOTS of different directions with Bayes
theorem, but one common approach is to set up a binary Bayes formula -
meaning only two possible outcomes can exist, R or (not R):
P(R|S) = P(S|R) P(R) / (P(S|R) P(R) + P(S|not R) (1-P(R))

With this simple formula, we can now incorporate new data into our
experience. Say we had two mutually exclusive hypotheses - you can call them
"flatter" or "sharper", "hotter" or "colder", "good" or "bad", whatever - as
new evidence is brought in, we can update the weighting of the two
hypotheses. This is done by a simple additive process when we take the log
of the binary Bayes formula (actually best expressed by taking a ratio of
Bayesian probabilities called the odds). For more hypotheses than two, the
simple additive process does not work out so well, however, so this was one
justification I had for choosing the binary Bayes formula.

A common question, and one that has caused lots of arguments, is how then to
think about the first prior probability, whether it can exist or if it must
come from observation, what data it should be based on, etc. One
mathematically justified approach is, in the complete absence of any
information about the system (and this is more rare than it sounds like,
since even describing a problem or a solution method implies information),
to use the "Jeffreys prior probability", but even this is under a bit of
contention. I chose to initialize the probability at 1/2. I believe that is
most common. I think one possible alternative is to initialize at 0.5^0.5,
but I'm not really sure.

The reason the Bayes theorem might make a good tuning is for the same reason
that the golden ratio might. It describes a well-ingrained process that
directs the course of development and perception. Therefore, one might
expect that we are very adept at picking up on the results of these
calculations. The Bayes formula is prominent in artificial neural networks.
The association I made with the poly-Bernoulli numbers may have significant
implications for our perceptive processes, which I won't try to describe at
the moment (its very late).

Anyway, the binary Bayes formula uses 2 variables essentially - the prior
probability and the likelihood ratio. The prior probability is simply
updated each round, so we have no control over that excepting its initial
value. The likelihood ratio (which I express in the program as exp(k)) can
be adjusted, however, so that after N steps we arrive at the 2/1 octave. The
really surprising thing was that simply by inverting the likelihood ratio
(and, BTW, this inversion has a very straightforward implication in its
association to the poly-Bernoulli numbers) we get a 3/2 range (in the
opposite direction) instead of the 2/1. That seems to hint that it might
have some harmonic interpretation (and it is somewhat tempting to try to use
the tritave that could be made from the two ranges together).

(ADDENDUM: Correction to the OP - Kaneko published that paper in '97, not
'99)

🔗Daniel Nielsen <nielsed@...>

5/21/2011 1:41:58 AM

On Mon, Apr 25, 2011 at 12:02 AM, Daniel Nielsen <nielsed@...> wrote:

> This is a set of tunings based on the Bayes formula.
>
> How it is generated:
> It assumes a binary Bayes process (i.e. two exhaustive, mutually exclusive
> possible outcomes) with an initial prior probability for "success" of 1/2.
> From there, a likelihood ratio is found that causes the value after N
> iterative evaluations to fall on the 2/1 octave. (N, therefore, is the
> number of pitches in the octave, since the value at each iteration
> represents a pitch.)
>
> Here are results for N=9, as an example:
> 0.0000
> -108.8867
> -224.1946
> -345.8528
> -473.7450
> -607.7137
> -747.5635
> -893.0673
> -1043.9709
> -1200.0000
>
> Why are these negative? Well, I wasn't certain whether to add another
> octave or to invert the values to make a tuning. What's interesting is that,
> if we invert the likelihood ratio that defines this set, we get a 3/2 range
> in the opposite direction instead. Values are the following (again using the
> example of N=9):
> 0.0000
> 102.4416
> 198.4620
> 288.1322
> 371.5683
> 448.9280
> 520.4065
> 586.2311
> 646.6557
> 701.9550
> (blah blah blah...)
>

Don't know if anyone remembers these two sets of values based on a binary
Bayesian process with reciprocal likelihoods. It occurred to me to try to
make a scale in the 3tave by subtracting one set from the other. What does
this give? It simply gives N-ED3. In this way Bayesian understandings might
be considered a further decomposition of EDn form, producing the EDn state
when a Bayesian balancing act occurs. In this case 3/1 is formed by a
"balancing act" of 2/1 and 3/2-period scales.

Then it occurred to me why ED3 was produced: This is essentially just
log-of-odds updating (http://www-biba.inrialpes.fr/Jaynes/cc04q.pdf). This
explains why, within each set of values, the differences are not constant,
but when taken together subtractively they are.

🔗lobawad <lobawad@...>

5/21/2011 8:51:26 AM

Was this done in the logarithmic realm or the frequency realm? Whichever it was, what would be the other version?

At any rate, both scales seem to have an audible acoustic continuity to them- proportional beating or something, I don't know. Maybe it's just a matter of them being comprised of intervals which are very close to intervals I'm accustomed to.

--- In tuning@yahoogroups.com, Daniel Nielsen <nielsed@...> wrote:
>
> On Mon, Apr 25, 2011 at 12:02 AM, Daniel Nielsen <nielsed@...> wrote:
>
> > This is a set of tunings based on the Bayes formula.
> >
> > How it is generated:
> > It assumes a binary Bayes process (i.e. two exhaustive, mutually exclusive
> > possible outcomes) with an initial prior probability for "success" of 1/2.
> > From there, a likelihood ratio is found that causes the value after N
> > iterative evaluations to fall on the 2/1 octave. (N, therefore, is the
> > number of pitches in the octave, since the value at each iteration
> > represents a pitch.)
> >
> > Here are results for N=9, as an example:
> > 0.0000
> > -108.8867
> > -224.1946
> > -345.8528
> > -473.7450
> > -607.7137
> > -747.5635
> > -893.0673
> > -1043.9709
> > -1200.0000
> >
> > Why are these negative? Well, I wasn't certain whether to add another
> > octave or to invert the values to make a tuning. What's interesting is that,
> > if we invert the likelihood ratio that defines this set, we get a 3/2 range
> > in the opposite direction instead. Values are the following (again using the
> > example of N=9):
> > 0.0000
> > 102.4416
> > 198.4620
> > 288.1322
> > 371.5683
> > 448.9280
> > 520.4065
> > 586.2311
> > 646.6557
> > 701.9550
> > (blah blah blah...)
> >
>
>
> Don't know if anyone remembers these two sets of values based on a binary
> Bayesian process with reciprocal likelihoods. It occurred to me to try to
> make a scale in the 3tave by subtracting one set from the other. What does
> this give? It simply gives N-ED3. In this way Bayesian understandings might
> be considered a further decomposition of EDn form, producing the EDn state
> when a Bayesian balancing act occurs. In this case 3/1 is formed by a
> "balancing act" of 2/1 and 3/2-period scales.
>
> Then it occurred to me why ED3 was produced: This is essentially just
> log-of-odds updating (http://www-biba.inrialpes.fr/Jaynes/cc04q.pdf). This
> explains why, within each set of values, the differences are not constant,
> but when taken together subtractively they are.
>

🔗Daniel Nielsen <nielsed@...>

5/21/2011 9:54:44 AM

On Sat, May 21, 2011 at 10:51 AM, lobawad <lobawad@...> wrote:

>
>
> Was this done in the logarithmic realm or the frequency realm? Whichever it
> was, what would be the other version?
>
> At any rate, both scales seem to have an audible acoustic continuity to
> them- proportional beating or something, I don't know. Maybe it's just a
> matter of them being comprised of intervals which are very close to
> intervals I'm accustomed to.
>

If you are talking about the cents listed, then it was done in
log-probability (since cents are logarithmic values). Apparently I didn't
explicitly state that $12.00 was added to the results to make each start at
0 cents (although you can see that in the BASIC program in the OP), so
hopefully that clears things up if you were wondering how a probability of
2/1 might exist - it doesn't, it's really 1/1. I think at the time of the
OP, I was trying to keep my explanation as simple and stripped-down as
possible.

Also, while it seems true that
"...why ED3 was produced: This is essentially just log-of-odds updating (
http://www-biba.inrialpes.fr/Jaynes/cc04q.pdf). This explains why, within
each set of values, the differences are not constant, but when taken
together subtractively they are."
I haven't managed yet to prove it this morning.

🔗Daniel Nielsen <nielsed@...>

5/21/2011 9:59:26 AM

Cameron:
"At any rate, both scales seem to have an audible acoustic continuity to
them- proportional beating or something, I don't know. Maybe it's just a
matter of them being comprised of intervals which are very close to
intervals I'm accustomed to."

Yeah, I'm not completely sure either. I tend to think that they sound
exceptionally good due to distinctive qualities, but that could be bias
talking.

🔗genewardsmith <genewardsmith@...>

5/21/2011 10:24:15 AM

--- In tuning@yahoogroups.com, Daniel Nielsen <nielsed@...> wrote:
> I think at the time of the
> OP, I was trying to keep my explanation as simple and stripped-down as
> possible.

I think instead you should give very explicit formulas and post to tuning-math.

🔗lobawad <lobawad@...>

5/21/2011 11:49:12 PM

Whatever the reason, the scales and resulting vertical sonorities, including more clustered intervals, sound good to me, too.

--- In tuning@yahoogroups.com, Daniel Nielsen <nielsed@...> wrote:
>
> Cameron:
> "At any rate, both scales seem to have an audible acoustic continuity to
> them- proportional beating or something, I don't know. Maybe it's just a
> matter of them being comprised of intervals which are very close to
> intervals I'm accustomed to."
>
> Yeah, I'm not completely sure either. I tend to think that they sound
> exceptionally good due to distinctive qualities, but that could be bias
> talking.
>

🔗Daniel Nielsen <nielsed@...>

5/22/2011 1:11:50 PM

Hi, are you subscribed to tuning-math? That's where I'm doing the follow-up
on this. Feel free to post here, though, and I'll definitely reply. Another
interesting thing to try might be to perform a dynamic Bayesian process that
doesn't necessarily always fall on pitches of a predefined scale. I don't
know what hypotheses and collection of data would drive this process,
though.

Dan N