Music21: chord to parts - music21

How could I convert chords into parts (or voices) with Music21? I need the opposite result of the chordify function.
For instance, I need to convert the first excerpt into the second one.

Related

How to compare two arrays containing points to finding out the percentage of similarity?

Suppose we've 10 arrays like below sample
Every element of those array has two parts: the section number, time the cursor was there in second(for e.g in 3rd and 10th seconds cursor was in that section)
By the way, if they give the new array; we need to compare new one with our model and then show the similarity percentage for them to score the actions.
I really have no idea should I use any clustering or classification methods and if yes how it should be for arrays(we always learned about element of an array or some vectors in university)
I found something in Jiawei Han, Micheline Kamber, Jian Pei Data mining book. what do you think about Cosine similarity?
but we need to convert that array to another including Section numbers and Frequency of refers.
converted array

How to use computed values inside a function that demands an array

There's a handy Excel function called SMALL that lets you find the n-th smallest value from an array. For example: SMALL({35;10;5000;6},2) = 10, the second smallest number in the set.
You could use this function by referencing an array of cells (SMALL(A1:A10,2)) or you can write an array of constant values in the formula directly (SMALL({1;2;3},2)).
Is there a way to write an array of computed values directly in the formula? It should look something like this, if using RAND to generate the values:
SMALL({RAND();RAND();RAND()},2)
but Excel doesn't allow that.
How can you use a function (like RAND) inside another function that demands an array (like SMALL)?
Yes, I'm aware that the usual solution would be to put the computed values in their own individual cells, then just use that array as the input of SMALL. It would be great if I could do this all inside a single cell.
The general answer as you may know is that you would use an array formula.
This is a bit difficult to illustrate with RAND(), but if you take a more normal function like SQRT, the usage would be
=SMALL(SQRT({9,4,1}),1)
so instead of providing a single argument to SQRT, you are providing a list of arguments which it is going to work through one at a time and return an array of 3 elements {3,2,1} which is passed to SMALL to evaluate.
If the same list of numbers was in (say) A1:A3, you would need to enter this as an array formula using CtrlShiftEnter
=SMALL(SQRT(A1:A3),1)
But as pointed out by #Jeeped, it's often more convenient to use AGGREGATE
=AGGREGATE(15,6,SQRT(A1:A3),1)
As far as I know, you can't reproduce this behaviour with RAND because it is one of the few Excel functions that takes no arguments.
If you really did want to generate an array of random numbers r where 0<=r<1 , you would have to do something like this
=SMALL((RANDBETWEEN({0,0,0},10^20-1)/10^20),1)
i.e. use RANDBETWEEN with an arbitrarily large upper limit.

Sorting an array of URLs

I have an array with quasar URLs stored in it
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/26/spectra/0269/spec-0269-51581-0467.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/26/spectra/0329/spec-0329-52056-0059.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/104/spectra/2957/spec-2957-54807-0164.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/26/spectra/0342/spec-0342-51691-0089.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/26/spectra/2881/spec-2881-54502-0508.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/26/spectra/0302/spec-0302-51616-0435.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/26/spectra/2947/spec-2947-54533-0371.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/26/spectra/0301/spec-0301-51942-0460.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/104/spectra/2962/spec-2962-54774-0461.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/26/spectra/2974/spec-2974-54592-0185.fits
I want to sort out the URL array on basis of the number next to spec- and not using alphabetic order. I sorted the array with sort but it didn't help as it always took the 3rd row and 2nd last row to the top because they have a 1.
I'd like to have an output like this
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/26/spectra/0269/spec-0269-51581-0467.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/26/spectra/0301/spec-0301-51942-0460.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/26/spectra/0302/spec-0302-51616-0435.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/26/spectra/0329/spec-0329-52056-0059.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/26/spectra/0342/spec-0342-51691-0089.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/26/spectra/2881/spec-2881-54502-0508.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/26/spectra/2947/spec-2947-54533-0371.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/104/spectra/2957/spec-2957-54807-0164.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/104/spectra/2962/spec-2962-54774-0461.fits
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/26/spectra/2974/spec-2974-54592-0185.fits
If you will always have this pattern, you can try:
fileName = strsplit(myUrl, '/')(end)
number = strsplit(fileName(5:end), '.')(0)
Gonna walk you through this cause understanding is everything...
We start with
http://dr12.sdss3.org/sas/dr12/sdss/spectro/redux/26/spectra/0269/spec-0269-51581-0467.fits
First we split the URL on the / characters. This will return a vector of strings split up from this character. Since the number to sort on resides after the final /, we can pass end to grab the last one. Now we have
spec-0269-51581-0467.fits
Next, let's remove that pesky spec- from the number. This step isn't actually necessary, since it's constant across all the URLs, but let's just do it for fun. We can use Matlab's substring to grab the characters after the -, using fileName(5:end). This will create a string starting with the 5th character (in this case, a 0) and continue to the end. Great, now we have
0269-51581-0467.fits
Looking good! Again, this part isn't completely necessary either, but just in case for whatever reason you may need to, I've included it. We can use the strsplit function again, but this time split on the ., and grab the first element by passing a 0. Now, we have
0269-51581-0467
Go ahead and sort that little guy and you're good to go!

PyBrain: passing empty floats or switching them with neutral values?

Right now, I am trying to pass this for a dataset sample:
7/2/2014,7:30,138.885,138.87,138.923,,,,138.88067,138.91434,138.895,,,,138.89657 14,138.9186042,138.8745387,138.923,138.9046667,138.895,138.8696667
But predictably, it gives me a value error since empty strings can't be converted into floats. What I want to do is to pass those empty variables in such a way the associated nodes will do nothing at all, or there won't be a learning, nothing will change etc.
Is there any way to do this?
(There is method for converting the timestaps, I just need to handle the empty strings)
There are a number of ways, but one is to calculate the average value of that column, and pass that in any case where there is missing data. You can also add a column that is True/False for whether or not the data is present, so that the network has the ability to learn that the first column is important only when the second column is True.

what does the 0x0022f844 in the value column of watch represent while debugging?

I use VC2010 and I see that the same data is represented differently while debugging and writing.
for example : 37487840ca673239dc72f9eeb746947a is represented as
0x0022f844 "37487840ca673239dc72f9eeb746947a" unsigned char [33]
and
0x0022f670 "48598840ca673239dc72f9eeb746947a" unsigned char [33]
I want the first representation but the second one is written to files instead of the first one.
EDIT:
the first and the second values need to be same because the second one is just a copy of the first one. Actually I passed the first value as an argument to a function and the second value represents it before anything is done in this function.
0x0022f844 is an example of hexadecimal number. That's (by default) the format used to display addresses. So that value, that vary from run to run, it's the 'human understandable' representation of the address of the memory area where the value resides. It's useless to put it in a file. Store your value instead.
The value in the left hand column is the address of the array. Since the array is of a fixed size Visual Studio is displaying all of it's elements in the value column.
Here there are two different addresses and hence two different values are displayed.
The first part (0x...) is the address of the variable you're watching. What follows is a printout of the contents of memory at that address.
The second variable/memory area you're watching is not "a representation of" 37487..., it contains a different value.

Resources