text:
Notating Stochastic Music with DISSCO<!-- --> | <!-- -->Andreworals.com

# Notating Stochastic Music with DISSCO

This past summer, I interned with NCSA at U of I and worked on a project notating stochastic (random) music. The project revolved around a piece of software called DISSCO, or the Digital Instrument for Sound Synthesis and Composition, managed and originally developed by Dr. Sever Tipei. I had a great time working on this project and it gave me an opportunity to solve an interesting problem, learn how to navigate a huge codebase, write documentation 😬 and level-up my c++ 🤓. Here's a brief overview of what I did (which is detailed in this paper and presentation) and my thoughts.

## What is DISSCO?

DISSCO is software for computer-assisted algorithmic composition. It is essentially a black-box function that takes in an XML file defining parameters of a composition, performs computations based on these parameters, and then outputs the score as either a sound file or a written score in western notation. The overarching concept is that the person and the computer work together to create a composition, where the human contributes their skill in making artistic decisions, while the computer contributes its "skill" in performing computations quickly. Although you can make deterministic music with DISSCO, it leans heavily towards compositions whose parameters are modulated with a degree of randomness.

## The problem

There are three parts to DISSCO: the GUI for making the XML files, the composition module, and then the additive synthesis module. I was mostly concerned with the composition module (CMOD), because this is what performs the computations for the piece.

### DISSCO's Event Structure

Internally, CMOD stores the entire piece as a tree, where the nodes are Event objects and the leaves are Note objects to be synthesized or notated. The only rules are that the topmost event must represent the piece as a whole, there must be at least one bottom event, and child events may only be placed inside their parent's duration. This tree structure represents the piece in layers of abstraction, where the "Top" event represents the piece as a whole, while, for example, its child might represent movements of the piece, and its child might represent sections of the movement, all the way down to the lowest level of abstraction, which could represent a melody or a chord.

Fundamentally, an event has a start time in seconds relative to the beginning of the piece, a duration in seconds, sometimes a Tempo, and then its children, which are also events or a subclass of Event, Bottom. This structure lends itself naturally to sound synthesis, however not so much to human performance. Unfortunately, most humans don't play music from timestamps; instead, people play music by subdividing and combining units of time in ratios. Then, in order to notate DISSCO's events, there needs to be some concept of discrete positioning on an evenly spaced grid. This is where the EDU comes in.

### EDU's

The EDU (Elementary Displacement Unit) is the basic unit of time in an exact "section" of a DISSCO piece. Exact events additionally have a start time and duration in EDU's, along with a tempo defining the number of EDU's per beat, the number of beats per measure, and also the number of beats per a unit of time (maybe a minute). Any exact children of an exact event inherit the tempo, so this creates an exact "section," which is what can be notated. There are a whole bunch of rules about what happens with different combinations of exact and inexact events, but what matters is that only exact sections which trickle all the way down the tree and produce exact leaves make it into the notated score.

### Previous work

The problem is then notating these discretely-positioned events. Previous work developed reliable methods of notating single musical lines with a uniform tempo and time signature. However, it only functioned on a specific case of compositions, where the top event was exact and this exactness then trickled down through the whole tree, making the tempo implicitly uniform. The previous implementation also had a few more technical issues that needed to be addressed:

• all the notation functionality was implemented as static functions in the Note class
• the temporary score data for notation was stored in the global namespace
• there was very little documentation, some of which was misleading or outdated
• no unit tests

## Goals

1. Implement and test functionality for notating multiple exact sections separated by other events
2. Improve the documentation and modularity of the notation module

## Refactoring the notation module

Before implementing anything new I completely refactored the notation module to leverage object-oriented design and documented it. This ended up taking dozens of hours following the control flow in gdb and combing through lines of code. What I ended up doing was taking a set of input XML files, running them through CMOD, and then writing down all of the functions related to notation that were called and in what order. After enough inputs, this made a nice call graph that showed two major flows in creating the score: adding the notes to the score while ensuring that the notes are valid in the time signature, and building the score, which quantizes the final output to the EDU grid and finally outputs the score to a text file for lilypond.

Since the existing implementation could handle exact sections, I abstracted the notation logic into a Section class. The previous implementation stored data in two main places: a two-dimensional vector holding pointers to vectors representing bars containing notes, and a one-dimensional vector containing pointers to notes of the flattened score. I ended up keeping these two data structures but scrapping the vector pointers. Then I created a new interface, clearly delimiting the different stages of creating a section.

class Section {
public:
Section(TimeSignature time_signature);

Section(const Section& other);

Section& operator=(const Section& other);

~Section();

bool InsertNote(Note* n);

void SetDurationEDUS(int edus);

float GetStartTimeGlobal() const;

int CalculateEDUsFromSecondsInTempo(float seconds);

void Build(bool notate_time_signature);

const list<Note*>& GetSectionFlat();

//// Private members omitted for brevity ////
};

## Extending the functionality

After making the notation logic instantiable, it was time to enable creating multiple of these sections from Tempo objects in the score and stitch them together. This necessitated a section manager, called the NotationScore class. The notation score has an interface for adding new sections from Tempo objects, inserting notes into the score, building the score, and finally outputting the score to a text file for compilation with lilypond.

class NotationScore {
public:
NotationScore();

/**
* Construct a notation score with the provided title.
**/
NotationScore(const string& score_title);

/**
* Insert a Tempo into this score.
**/
void RegisterTempo(Tempo& tempo);

/**
* Insert a Note into this score.
**/
void InsertNote(Note* n);

/**
* Build the text representation of this score by adding bars,
**/
void Build();

/**
* Output the text representation of a score.
**/
friend ostream& operator<<(ostream& output_stream,
NotationScore& notation_score);

//// Private members omitted for brevity ////
};

## Inserting new sections into the score

Inside the composition module, there is no object explicitly representing a notation section. A notation section is just an exact parent and its exact descendants in the event tree. However, the Tempo objects are inherited through exact sections, so Bottom objects have a reference to the exact section's tempo. Then, when notes are added to the score, the bottom event simply calls RegisterTempo on the score object with its own tempo, representing the exact section. If the tempo doesn't already exist it's added to the score, and then the note is added to the new section.

You might think this sounds ridiculous–why not just append the new sections as the events are built? Unfortunately events are not necessarily built in chronological order, and a section can be composed of any number of bottom events, so each tempo needs to be checked against the score before insertion.

### Distributing Note objects into sections

A significant issue that came up is finding the sections into which to insert notes. Since events aren't necessarily built chronologically, notes aren't either, so the score can't be built on the fly. Instead, notes carry a pointer to the "root exact ancestor" from which the exact section is derived. Tempo objects carry this same pointer, and the notes and tempos are matched when the note is inserted.

## Joining notation sections

So now we can create multiple sections of notation, but how do we stitch them together? It's very unlikely that they will meet perfectly, and if they don't, it's also likely that the time span between the two events is not writable in western notation. In most cases, this is resolved by inserting a bar of shortened or lengthened time (a new Section) relative to the rhythm of the previous section.

For example, given sections $S_1$ and $S_2$, after building $S_1$ will have used some quantity of its allotted EDU's leaving a remainder $r$, and its last bar with some quantity of EDU's $b$. If $r < 0$, then the sections overlap and an error is produced. If both $r = 0$ and $b = 0$, the sections align perfectly. In all other cases, Section uses an algorithm with the following pseudocode:

pow_2 = 0
min_err = INT_MAX
time_signature_num = 0
time_signature_den = 0

while (prev_section_beat_edus % 2^pow_2 == 0):

tmp_beat_edus = prev_section_beat_edus / 2^pow_2

if ((r + b) % tmp_beat_edus == 0):

// Overhanging time forms a dyadic time signature
time_signature_num = (r + b) / d
time_signature_den = prev_section_unit_note * 2^pow_2
min_err = 0
break

else:

// or rest with the least error
num_beats = (r + b) / tmp_beat_edus + 1
err = tmp_beat_edus * num_beats - total_edus_to_use

if (err < min_err):

ts_num = num_beats
ts_den = prev_section_unit_note * 2^pow_2
min_err = err

pow_2 = pow_2 + 1

## Conclusion

Overall, I had a great time solving these problems this summer and learned much more about c++, writing modular code, and even writing documentation 😬. It was also a great opportunity to get better at communicating my ideas and pruning things down to only the most essential points. Anyway, thanks for reading!

Andreworals.com


text:
# Strange issues fitting GMMs in Turing.jl by extending a fairly simple example

I have been extending the Turing example on Bayesian GMMs today in a number of ways, trying it out with non-symmetric 2D Gaussian locations and more clusters than the two in the example I have linked, and namely with some more tightly distributed components. This is where I have run into a problem I am struggling to diagnose and wondering if it is something looking into further. I first pick my parameters and generate some data:

using Distributions, StatsPlots, Random, KernelDensity

# Set a random seed.
Random.seed!(3)

N = 100

# Parameters for each cluster, we assume that each cluster is Gaussian distributed in the example.
f(iterators...) = vec([collect(x) for x in Iterators.product(iterators...)])
μs = f([0:1:1, 0:1:1]...)

σ_true = 0.25

β = 5
α = (β / σ_true) - 1

K = length(μs)

gmm = MixtureModel(
MvNormal.(μs, σ_true)
)

x = rand(gmm, N)

plot(kde(transpose(x)), title="Real Data")

This all goes smoothly and results in 4 components at each corner of the [0,1] square, I then define my model which is the same as the one in the linked example except we also learn a variance common to all the components and we aren’t restricted to the “x” and “y” locations being equal for each component, this works pretty well:

using Turing, MCMCChains, DataFrames, FillArrays, StatsBase, Zygote

@model GaussianMixtureModel(x, K) = begin

D, N = size(x)

# Draw the parameters for cluster 1.
μ1 ~ filldist(Normal(), K)
μ2 ~ filldist(Normal(), K)
# Uncomment the following lines to draw the weights for the K clusters
# from a Dirichlet distribution.

σ ~ InverseGamma(α, β)

w ~ Dirichlet(K, 1.0)

# Comment out this line if you instead want to draw the weights.
# w = Fill(1 / K, K)

# Draw assignments for each datum and generate it from a multivariate normal.
k = Vector{Int}(undef, N)
for i in 1:N
k[i] ~ Categorical(w)
x[:,i] ~ MvNormal([μ1[k[i]], μ2[k[i]]], σ)
end
return k
end

gmm_model = GaussianMixtureModel(x, K)
gmm_sampler = Gibbs(PG(100, :k), HMC(0.05, 10, :μ1, :μ2, :σ))
tchain = sample(
gmm_model,
gmm_sampler,
100
)

As we get the following result:

Chains MCMC chain (100×9×1 Array{Float64,3}):

Iterations        = 1:100
Thinning interval = 1
Chains            = 1
Samples per chain = 100
parameters        = μ1[1], μ1[2], μ1[3], μ1[4], μ2[1], μ2[2], μ2[3], μ2[4], σ
internals         =

Summary Statistics
parameters      mean       std   naive_se      mcse        ess      rhat
Symbol   Float64   Float64    Float64   Missing    Float64   Float64

μ1[1]   -0.0056    0.0748     0.0075   missing    65.7362    0.9919
μ1[2]    0.8684    0.0663     0.0066   missing    48.8895    1.0249
μ1[3]   -0.0227    0.0415     0.0041   missing    49.3505    1.0110
μ1[4]    1.0091    0.0584     0.0058   missing   154.4181    0.9965
μ2[1]   -0.0428    0.0649     0.0065   missing    96.1578    0.9958
μ2[2]   -0.0445    0.0612     0.0061   missing    55.1864    0.9903
μ2[3]    1.0109    0.0497     0.0050   missing    40.8658    1.0210
μ2[4]    0.8448    0.0649     0.0065   missing   106.4267    0.9913
σ    0.2560    0.0161     0.0016   missing    30.7763    1.0707

Quantiles
parameters      2.5%     25.0%     50.0%     75.0%     97.5%
Symbol   Float64   Float64   Float64   Float64   Float64

μ1[1]   -0.1235   -0.0680   -0.0088    0.0606    0.1347
μ1[2]    0.7557    0.8169    0.8696    0.9140    0.9999
μ1[3]   -0.1105   -0.0533   -0.0203    0.0045    0.0457
μ1[4]    0.9032    0.9717    1.0161    1.0417    1.1016
μ2[1]   -0.1538   -0.0903   -0.0455    0.0004    0.0760
μ2[2]   -0.1634   -0.0864   -0.0433    0.0026    0.0553
μ2[3]    0.9242    0.9666    1.0141    1.0453    1.0953
μ2[4]    0.7104    0.8024    0.8390    0.8825    0.9661
σ    0.2287    0.2435    0.2552    0.2666    0.2883

However, everything falls apart when I simply reduce σ_true a bit to say 0.05:

Chains MCMC chain (100×9×1 Array{Float64,3}):

Iterations        = 1:100
Thinning interval = 1
Chains            = 1
Samples per chain = 100
parameters        = μ1[1], μ1[2], μ1[3], μ1[4], μ2[1], μ2[2], μ2[3], μ2[4], σ
internals         =

Summary Statistics
parameters      mean       std   naive_se      mcse       ess      rhat
Symbol   Float64   Float64    Float64   Missing   Float64   Float64

μ1[1]    1.2987    0.0000     0.0000   missing       NaN       NaN
μ1[2]    0.8141    0.0000     0.0000   missing    2.0408    0.9899
μ1[3]    0.2800    0.0000     0.0000   missing       NaN       NaN
μ1[4]   -0.3730    0.0000     0.0000   missing       NaN       NaN
μ2[1]   -0.0028    0.0000     0.0000   missing    2.0408    0.9899
μ2[2]    1.0843    0.0000     0.0000   missing    2.0408    0.9899
μ2[3]   -0.9647    0.0000     0.0000   missing    2.0408    0.9899
μ2[4]   -0.0501    0.0000     0.0000   missing       NaN       NaN
σ    0.0544    0.0000     0.0000   missing    2.0408    0.9899

Quantiles
parameters      2.5%     25.0%     50.0%     75.0%     97.5%
Symbol   Float64   Float64   Float64   Float64   Float64

μ1[1]    1.2987    1.2987    1.2987    1.2987    1.2987
μ1[2]    0.8141    0.8141    0.8141    0.8141    0.8141
μ1[3]    0.2800    0.2800    0.2800    0.2800    0.2800
μ1[4]   -0.3730   -0.3730   -0.3730   -0.3730   -0.3730
μ2[1]   -0.0028   -0.0028   -0.0028   -0.0028   -0.0028
μ2[2]    1.0843    1.0843    1.0843    1.0843    1.0843
μ2[3]   -0.9647   -0.9647   -0.9647   -0.9647   -0.9647
μ2[4]   -0.0501   -0.0501   -0.0501   -0.0501   -0.0501
σ    0.0544    0.0544    0.0544    0.0544    0.0544

Here it seems that no new values are accepted throughout sampling and it just remains at whatever it manages to initially sample, I am not sure why sampling would break down in this way, unless I am missing something obvious, I have spoken to a couple of people and read around, know that MCMC struggles with GMMs but cannot really think where to start in trying to fix this, so welcome any ideas / improvements to the more general GMM model I have formulated.

Any help would be appreciated, thanks!

One thing might be that this should be a TArray:

k = TArray(Int, N)

1 Like

There might be a few issues here. One potential issue is that the posterior density is concentrated in a small area when sigma is small, making it hard for the sampler to find high density areas. This might be exacerbated by performance issues with PG. You might try reparameterization or initializing the sampler in high density areas. In addition, marginalization might help. See this other thread.

2 Likes

Hi, can you integrate you the discrete variables or do you want to sample them with Turing?

Anyways, so here is an implementation of the GMM model when using particle Gibbs.

@model GaussianMixtureModel(x, K) = begin

D, N = size(x)

μ ~ filldist(MvNormal(zeros(D), 1), K)
σ ~ filldist(InverseGamma(α, β), K)

w ~ Dirichlet(K, 1.0)

k = TArray(Int, N)
for i in 1:N
k[i] ~ Categorical(w)
x[:,i] ~ MvNormal(μ[:,k[i]], sqrt(σ[k[i]]))
end
return k
end

gmm_model = GaussianMixtureModel(x, K)
gmm_sampler = Gibbs(PG(10, :k), HMC(0.05, 10, :μ, :σ, :w))
tchain = sample(
gmm_model,
gmm_sampler,
100
)

Alternatively, you can use the GibbsConditional to sample the discrete variables. This should be more efficient. The function for the Gibbs conditional should look something like this:

function cond_k(c; x=x)
K = length(c.w)
N = size(x, 2)
dists = map(1:N) do n
logp = map(k -> log(c.w[k]) + logpdf(MvNormal(c.μ[:,k], sqrt(c.σ[k])), x[:,n]), 1:K)
return Categorical(softmax!(logp))
end
return arraydist(dists)
end

gmm_sampler = GibbsConditional(:k, cond_k), HMC(0.05, 10, :μ, :σ, :w))

but I haven’t tried it. So you might have to fix some minor errors I made.

If you only want speed and don’t care about the discrete parameters then you might want to write:

function logpfun(x, μ, σ, w)
logw = log.(w)
K = length(logw)
N = size(x,2)
sum( sum( logw[k] + logpdf(MvNormal(μ[:,k], sqrt(σ[k]), x[:,n]) for k in 1:K) for n in 1:N)
end

@model GaussianMixtureModel(x, K) = begin

D, N = size(x)

μ ~ filldist(MvNormal(zeros(D), 1), K)
σ ~ filldist(InverseGamma(α, β), K)
w ~ Dirichlet(K, 1.0)

end

gmm_model = GaussianMixtureModel(x, K)
gmm_sampler = NUTS(0.75)
tchain = sample(
gmm_model,
gmm_sampler,
100
)

2 Likes

Thank you for the comprehensive answer Martin I am trying this stuff out, I don’t really care for the discrete component assignments yeah so this version of integrating them out is attractive, except I think I am running into the classic identifiability issues associated with Bayesian Mixtures now (discussed in Betancourt’s blog here). I think roughly we need to somehow impose an order on the \mu as currently this does indeed work pretty fast but the outputs aren’t great:

using Distributions, StatsPlots, Random, KernelDensity

# Set a random seed.
Random.seed!(3)

# Construct 30 data points for each cluster.
N = 1000

# Parameters for each cluster, we assume that each cluster is Gaussian distributed in the example.

f(iterators...) = vec([collect(x) for x in Iterators.product(iterators...)])
μs = f([-3:6:3, -3:6:3]...)

σ²ₜ = 0.1

β = 2
α = (β / σ²ₜ) - 1

K = length(μs)

gmm = MixtureModel(
MvNormal.(μs, √σ²ₜ)
)

x = rand(gmm, N)

plot(kde(transpose(x)), title="Real Data")

using Turing, MCMCChains, DataFrames, FillArrays, StatsBase, Zygote

function logpfun(x, μ, σ², w)
logw = log.(w)
K = length(logw)
N = size(x, 2)
sum(sum(logw[k] + logpdf(MvNormal(μ[:,k], √(σ²[k])), x[:,n]) for k in 1:K) for n in 1:N)
end

@model GMM2(x, K) = begin

D, N = size(x)

μ ~ filldist(MvNormal(zeros(D), 10), K)
σ² ~ filldist(InverseGamma(α, β), K)
w ~ Dirichlet(K, 1.0)

end

gmm_model = GMM2(x, K)
gmm_sampler = NUTS(0.75)
tchain = sample(
gmm_model,
gmm_sampler,
100,
)

Results in:

Chains MCMC chain (100×12×1 Array{Float64,3}):

Iterations        = 1:100
Thinning interval = 1
Chains            = 1
Samples per chain = 100
parameters        = μ[1,1], μ[1,2], μ[1,3], μ[1,4], μ[2,1], μ[2,2], μ[2,3], μ[2,4], σ²[1], σ²[2], σ²[3], σ²[4]
internals         =

Summary Statistics
parameters      mean       std   naive_se      mcse         ess      rhat
Symbol   Float64   Float64    Float64   Missing     Float64   Float64

μ[1,1]   -0.0945    0.0850     0.0085   missing    216.8390    0.9965
μ[1,2]   -0.0861    0.1018     0.0102   missing   1847.2509    0.9932
μ[1,3]   -0.0961    0.0883     0.0088   missing    378.2921    0.9903
μ[1,4]   -0.0804    0.0948     0.0095   missing    530.6550    0.9917
μ[2,1]   -0.0239    0.1112     0.0111   missing    652.5307    0.9903
μ[2,2]   -0.0169    0.0937     0.0094   missing    178.1601    1.0152
μ[2,3]   -0.0283    0.1025     0.0102   missing    300.8100    0.9985
μ[2,4]   -0.0268    0.0813     0.0081   missing    218.1677    0.9900
σ²[1]    8.9500    0.2832     0.0283   missing     96.9495    1.0024
σ²[2]    8.9059    0.2923     0.0292   missing     92.0745    1.0378
σ²[3]    8.9507    0.3030     0.0303   missing    121.2856    0.9926
σ²[4]    8.9215    0.2604     0.0260   missing     23.1522    1.0476

Quantiles
parameters      2.5%     25.0%     50.0%     75.0%     97.5%
Symbol   Float64   Float64   Float64   Float64   Float64

μ[1,1]   -0.2448   -0.1526   -0.0968   -0.0448    0.0719
μ[1,2]   -0.2590   -0.1636   -0.0825   -0.0211    0.1102
μ[1,3]   -0.2883   -0.1556   -0.1070   -0.0352    0.0915
μ[1,4]   -0.2345   -0.1589   -0.0836   -0.0126    0.0976
μ[2,1]   -0.2250   -0.0867   -0.0270    0.0429    0.2036
μ[2,2]   -0.1856   -0.0902   -0.0086    0.0471    0.1695
μ[2,3]   -0.2024   -0.0837   -0.0262    0.0262    0.1745
μ[2,4]   -0.2074   -0.0857   -0.0226    0.0355    0.1116
σ²[1]    8.4068    8.7597    8.9321    9.1382    9.4191
σ²[2]    8.4053    8.6876    8.9105    9.0624    9.5809
σ²[3]    8.4262    8.7340    8.9049    9.1691    9.5304
σ²[4]    8.4053    8.7525    8.9500    9.1158    9.3155

As it must be struggling to identify the individual clusters. Do you know how we might impose an ordering on them, I have tried initialising the values at the high density areas as suggested by @Christopher_Fisher but to no avail.

Part of the problem is that log density of mixture components cannot be added with sum. Instead, you need to use logsumexp from StatsFuns in the inner summation. logsumexp is a numerically stable and accurate way to sum:

julia> w = [.2, .8]
2-element Array{Float64,1}:
0.2
0.8

julia> dens = [2.0,1.5]
2-element Array{Float64,1}:
2.0
1.5

julia> log(w'*dens)
0.47000362924573563

julia> logsumexp(log.(w) .+ log.(dens)) # =)
0.47000362924573563

julia> sum(log.(w) .+ log.(dens)) # =(
-0.7339691750802003

It appears to work better with the following function:

function logpfun(x, μ, σ², w)
logw = log.(w)
K = length(logw)
N = size(x, 2)
sum(logsumexp(logw[k] + logpdf(MvNormal(μ[:,k], √(σ²[k])), x[:,n]) for k in 1:K) for n in 1:N)
end

You should increase the number of samples because effective sample size is low and rhat is high in some cases.

2 Likes

Oh yeah, my fault. Sorry that was a stupid mistake.

No worries. I do something like that at least once a day.

2 Likes

Thanks for the help @Christopher_Fisher and @trappmartin, it is working now I think to some extent, initialising at the correct values also helps in this case for the sampling when variance is small. I have one further question which is really more of a hopeful one, do you have any tips for scaling this such that it might work with more clusters, naturally I feel larger number of samples / more data makes sense for if I wanted to have say 25 clusters, but wondered if there were any further tips you might have to improve the model? I presume the majority of the difficulty here arises from the multi-modality that grows in the number of components of the mixture, and so it might just be an inevitable uphill struggle.

As you add more clusters, ReverseDiff will have a larger and larger performance advantage. Unfortunately, there is a performance gap between ReverseDiff and Stan. But if I recall correctly, Stan also struggles with this particular type of model. Last time I inquired, there were a few efforts are developing new reverse AD packages, but those details were lost on Slack.

format: plain


text:
# Homework Help: Shear modulus

1. May 7, 2010

### Loligo

1. The problem statement, all variables and given/known data
The Shear modulus for aluminum and copper are 25GPa and 35GPa, respectively. An aluminum and copper pole, both the same length are subjected to the same shear force at the top of each pole, bending each pole a different angle y. Which pole has a higher angle of deflection and by how much?

2. Relevant equations
Formulas I am using are Shear Modulus = Shear Stress/Shear Strain
S = σ/ε = (F/A)/(Δx/Lo)
angle y = ε = Δx/Lo

3. The attempt at a solution
Since the forces are equal and area should be equal (under assumption the poles are the same dimensions the shear stress (σ) is equal for both poles.
Rearranging the formulas I get σ=S*y
σAC so 25GPa*yA=38GPa*yC
I get that the angle the deflection for the aluminum pole will be 1.52 times that of the copper pole.

2. May 7, 2010

### PhanthomJay

is it 35 or 38 GPa? Insert correct value and round off to one decimal point, and your result will be OK. Shear stress is usually designated as $$\tau$$, and shear modulus is usually referred to as $$G$$. This distinguishes it from normal stress ($$\sigma$$) and elastic modulus ($$E$$) used for normal strains.

3. May 7, 2010

### Loligo

The aluminum pole has a shear modulus of 25 GPa and the copper pole 35GPa.
Is it correct to say that the shear stress will stay the same with the poles are identical in proportions and are subjected to the same force

4. May 7, 2010

### PhanthomJay

Yes. The problem does not specifically state that both poles are similar in cross section, so it must be assumed that they are identically proportioned..


text:
Indico has been upgraded to version 3.1. Details in the SSB

# 12th International "Hiroshima" Symposium on the Development and Application of Semiconductor Tracking Detectors (HSTD12) at Hiroshima, Japan

Dec 14 – 18, 2019
International Conference Center Hiroshima
Japan timezone

## Performance evaluation of GAGG/LFS scintillator+MPPC array readout with ASIC

Dec 14, 2019, 3:16 PM
1m
POSTER - Sun: B1F-Meeting room#3, B2F-RAN1/2; Mon-Wed: B1F Meeting rooms #5-6 (International Conference Center Hiroshima)

### POSTER - Sun: B1F-Meeting room#3, B2F-RAN1/2; Mon-Wed: B1F Meeting rooms #5-6

#### International Conference Center Hiroshima

Peace Memorial Park, Hiroshima-shi
POSTER Applications in astrophysics

### Speaker

Mr Daiki Nobashi (Nagoya University)

### Description

In the soft gamma ray region (100 keV-10 MeV), Compton scattering is the dominant physical process, and It is an unexplored region where observation has not progressed because the background is rather high compared to the signal from celestial sources. In this region, the direction and energy of incident gamma rays can be determined by using Compton camera technique where photons are Compton scattered by a scatterer and then fully absorbed by an absorber. Recently, semiconductor detectors with excellent energy and position resolution are used in the Compton camera, but when observing higher energy than 1 MeV, it is required to develop an array-type detector in which scintillators with excellent gamma ray stopping power are assembled in the form of pixels as an absorber. So we constructed a gamma ray detector by combining two types of scintillator array detectors with an MPPC array, and evaluated the performance by reading out the signals from the MPPC with a low-power integrated circuit (ASIC) manufactured by IDEAS in Norway. One of the two types of scintillators is a GAGG (Ga$_3$Al$_2$Gd$_3$O$_{12}$) scintillator, and the other is an LFS scintillator. The scintillator array is 2.5 cm x 2.5 cm in size and is coated with BaSO$_4$-based white paint as a reflector except for the side optically coupled to the MPPC. The energy resolution of the GAGG array was about 7% at 662 keV at room temperature. This is almost equivalent to the typical energy resolution. In this presentation, we report on the performance evaluation of GAGG and LFS scintillator array.

Submission declaration Original and unpublished

### Primary author

Mr Daiki Nobashi (Nagoya University)

### Co-authors

Dr Kazutaka Yamaoka (Nagoya University ) Prof. Hiroyasu Tajima (Nagoya University) Mr Kazuya Ito (Nagoya University)

### Presentation materials

There are no materials yet.


text:
# zbMATH — the first resource for mathematics

Lattice-ordered groups. An introduction. (English) Zbl 0636.06008
Reidel Texts in the Mathematical Sciences. Dordrecht (Netherlands) etc.: D. Reidel Publishing Company. vii, 190 p. \$ 44.00; £29.50; Dfl. 98.00 (1988).
This book can serve as a clearly written and well-organized text for the introductory study of lattice-ordered groups. It consists of the following chapters: Fundamentals; Bernau’s representation for archimedian $$\ell$$-groups; The Conrad-Harvey-Holland representation; Representable and normal valued $$\ell$$-groups; Holland’s embedding theorem; Free $$\ell$$-groups; Varieties of $$\ell$$-groups; Completions of representable and archimedean $$\ell$$-groups; The lateral completion; Finite-valued and special valued $$\ell$$-groups; Groups of divisibility; Appendix: A menagerie of examples (varieties of $$\ell$$-groups; torsion and radical classes of $$\ell$$-groups; examples of lattice-ordered groups).
Most of the chapters contain the standard basic material on the subject under consideration. The chapters dealing with varieties of $$\ell$$-groups and with groups of divisibility are nearer to the up-to-date frontier (let us remark that the authors of the book also contributed to these questions). The Appendix (about 40 pages) will be certainly extremely useful not only for beginners but also for specialists in the field, in view of many skillfully chosen and valuable examples and counter- examples. In the rather exhaustive bibliography there are several misprints.
Reviewer: J.Jakubik

##### MSC:
 06F15 Ordered groups 06-01 Introductory exposition (textbooks, tutorial papers, etc.) pertaining to ordered structures 20-01 Introductory exposition (textbooks, tutorial papers, etc.) pertaining to group theory 20F60 Ordered groups (group-theoretic aspects)


text:
8th Grade ... Pre Algebra ... HELP!

• Sep 18th 2008, 06:01 PM
tatsing11
8th Grade ... Pre Algebra ... HELP!
(Worried) I have a math test tomorrow and idk how 2 do sum stuff.
im having trouble with how to:
Evaluate decimal numbers with a positive power
Evaluate decimal numbers with a negative power
Evaluate negative numbers with positive exponents
Evaluate negative numbers with negative exponents

I litterally skipped 2 grades worth of math. I skipped anything I would have learned in 6th and 7th grade math . (Wink) unfortunately, thats mostly what i need 2 be able 2 do this. I would luv if someone could SIMPLY xplain 2 me how to do these.(Bigsmile)
Thx so much,
Clueless
• Sep 18th 2008, 06:03 PM
Jhevon
Quote:

Originally Posted by tatsing11
(Worried) I have a math test tomorrow and idk how 2 do sum stuff.
im having trouble with how to:
Evaluate decimal numbers with a positive power
Evaluate decimal numbers with a negative power
Evaluate negative numbers with positive exponents
Evaluate negative numbers with negative exponents

I litterally skipped 2 grades worth of math. I skipped anything I would have learned in 6th and 7th grade math . (Wink) unfortunately, thats mostly what i need 2 be able 2 do this. I would luv if someone could SIMPLY xplain 2 me how to do these.(Bigsmile)
Thx so much,
Clueless

when you say "evaluate" what to you mean?

can't you just plug them into a calculator, or do you have to work them out by hand? do you know what raising a number to a positive power does? what about a negative power?
• Sep 18th 2008, 06:14 PM
tatsing11
Evaluation
by evaluate, i mean figure out the value of the number. such as this prob:
Evaluate: 32 would be 9. thats what our math teachr says so yep and um
im okay with positive numbers with negative powers and stuff but i have no idea about decimals or neg numbrs and neg powers

• Sep 18th 2008, 06:26 PM
Jhevon
Quote:

Originally Posted by tatsing11
by evaluate, i mean figure out the value of the number. such as this prob:
Evaluate: 32 would be 9. thats what our math teachr says so yep and um
im okay with positive numbers with negative powers and stuff but i have no idea about decimals or neg numbrs and neg powers

well, i am trying to get at what level of sophistication you require, but you are not telling me much

all i can say is that you treat the decimals just as you would whole numbers

example, $3.02^2 = 3.02 \times 3.02 = 9.1204$

or, $3.02^3 = 3.02 \times 3.02 \times 3.02 = 27.543608$

etc

if you have $3.02^{-2} = \frac 1{3.02^2} = \frac 1{9.1204} = 0.1096 \dots$
• Sep 19th 2008, 02:25 AM
tatsing11
srry
srry dude but i need an xplanation stilll. im only in 6th grde but im in 8th grade math so i stll dk how 2 do it
• Sep 19th 2008, 01:49 PM
weakmath
let me try to make this easier:

power means multiplying by it self
"to the power of" is often replace by ^

ex. 3 "to the power of" 4
3 ^ 4
3 multiplies by it self 4 times = 3x3x3x3 = 81

ok here are some rules you just have to memorize

1. if you have a negative number and you take the power of a odd number you will end up with a negative number

(-3) ^ 3 = (-3)x(-3)x(-3) = -27

2. if you have a negative number and you take the power of a even number you will end up with a positive number
3 ^ 4 = 3x3x3x3x = 81

3. when you take it to the power of a negative number, basicly just treat the minus sign as 1 over "the number"
3 ^ (-2) = 1 over 3^2 = 1/3 x 1/3 = 1/9
• Sep 19th 2008, 02:26 PM
icemanfan
Also, evaluating a number to a fractional power involves taking roots. For instance, $3^{1.5} = 3\sqrt{3}$.
• Sep 22nd 2008, 06:34 AM
sandgaara
Hi (Hi)well you see if you are haveing problems with this just do what i do talk to the teacher and ask if you can study more befor you take the tes or you can just ask to retake the test me my self have a test to take next class to day and it is all about this stuff i know all of it so im shour i gunna get an A(Happy)
• Sep 22nd 2008, 06:45 AM
sandgaara
plz help
can any one help me with a problem like this

5 to the 6th power times 6 to the 5th power divided by 9 to the 3 power

my teacher said if we can simplfie it and figer it out we get NO HOMEWORK FOR THE REST OF THE YEAR(Bow)(Bow)(Bow)
• Sep 22nd 2008, 06:49 AM
sandgaara
(Worried)well this is my last post i might talk to you guys later i guess Bye(Hi)(Bow)(Bow)(Bow)(Bow)(Bow)(Bow)(Bow)(Bow)(Bo w)(Bow)(Bow)(Bow)(Bow)(Bow)(Bow)(Bow)(Bow)(Bow)(Bo w)(Bow)(Bow)(Bow)(Bow)(Bow)(Bow)(Bow)(Bow)
• Sep 22nd 2008, 08:47 AM
masters
Quote:

Originally Posted by tatsing11
srry dude but i need an xplanation stilll. im only in 6th grde but im in 8th grade math so i stll dk how 2 do it

Sounds like you need some serious help in writing in plain English!
• Sep 22nd 2008, 12:32 PM
Jhevon
Quote:

Originally Posted by sandgaara
can any one help me with a problem like this

5 to the 6th power times 6 to the 5th power divided by 9 to the 3 power

my teacher said if we can simplfie it and figer it out we get NO HOMEWORK FOR THE REST OF THE YEAR(Bow)(Bow)(Bow)

well that's not fair.

by the way, post new questions in a new thread.

i will start you off though, you finish up. start by writing 6 as 3*2 and writing 9 as 3^2


text:
IFC 4.3.0.1 (IFC4X3) development

# 4.7.7.1.3 PolyCurve Profile Definition

Poly curve profile definitions define the closed two-dimensional curve used for the cross-section by a indexed poly curve having straight and circular arc segments.

The following diagram shows the generic classes and relationships used when applying this concept.


text:
Chemistry - How does an acid prevents or discourges oxidation of iron?

This is largely due to the extreme insolubility of iron (III) hydroxide, i.e. $\ce{Fe(OH)3}$.

One can write the oxidation reaction, somewhat simplified, as:

$$\ce{Fe^2+(aq) + 6 H2O(l) <=> Fe(OH)3(s) + 3 H3O+(aq)} + e^-$$

The $K_{sp}$ (solubility product) value for $\ce{Fe(OH)3}$ is very small: $2.79 \times 10^{-39}$ (Wikipedia).

From the equilibrium reaction it's easy to understand that acidic conditions (high $[\ce{H3O+}]$) push the equilibrium to the left, thus preventing the oxidation.

It also explains why Mohr's Salt resists oxidation much better than simple ferrous sulphate, as the ammonium ion provides some acidity.

In alkaline conditions the oxidation of ferrous ions to ferric ions is very fast.


text:
# beamer definition-list overlay: uncover definition later than entry

For educational purposes, I would like to uncover the definitions of my description items only after all the items themselves have been uncovered, like so:

\documentclass{beamer}
\begin{document}
\begin{frame}
\begin{overprint}
\begin{description}
\item<1->[Spam]
\onslide<3->{Eggs}
\item<2->[Cheese]
\onslide<4->{Tofu}
\end{description}
\end{overprint}
\end{frame}
\end{document}

However, this has the effect that both Spam and Eggs appear only on slide 3. I would like that in slide 1, I have Spam (but without any content), and in slide 3, I have Spam and Eggs. How can I achieve this?

An alternative would be to use a tabular environment, but I'm interested to see if it can be achieved with a description.

-

Something like this works:

\documentclass{beamer}

\newcommand\desctext[1]{%
\only<+(1)>{\mbox{}}%
\onslide<+(1)->{#1}}

\begin{document}

\begin{frame}
\begin{overprint}
\begin{description}
\item[Spam1]\desctext{Eggs1}
\item[Spam2]\desctext{Eggs2}
\item[Spam3]\desctext{Eggs3}
\item[Spam4]\desctext{Eggs4}
\end{description}
\end{overprint}

\end{frame}

\end{document}

For the ordering required (all labels first, then all descriptions), something like this can be done:

\documentclass{beamer}

\newcommand\desctext[2][]{%
\only<+(1)->{\mbox{}}%
\onslide<#1->{#2}}

\begin{document}

\begin{frame}
\begin{overprint}
\begin{description}
\item[Spam1]\desctext[5]{Eggs1}% add one to the number of items
\item[Spam2]\desctext[6]{Eggs2}
\item[Spam3]\desctext[7]{Eggs3}
\item[Spam4]\desctext[8]{Eggs4}
\end{description}
\end{overprint}
\end{frame}

\end{document}

-
Almost; in fact, I like to first have all the items appear, then all the descriptions. And I might want a finer-grained control in any case. But the \mbox{} does the trick to solve the problem. –  gerrit Oct 10 '12 at 17:15
@gerrit I updated my answer with a posibble definition for this new ordering; perhaps it can be simplified a little to elliminate the optional argument. –  Gonzalo Medina Oct 10 '12 at 17:29

Personally I use itemize environment to achieve your goal.

description environment seems to behave differently from itemize and enumerate environment for "complicated" constructions.

\documentclass{beamer}
\begin{document}
\begin{frame}
\begin{overprint}
\begin{itemize}
\item<1-> Spam:
\onslide<2->{Eggs}
\end{itemize}
\end{overprint}
\end{frame}
\end{document}

-


text:
# resolution based theorem prover for temporal logic

I am looking at implementing a a resolution-based theorem prover for propositional linear temporal logic (PLTL) (as opposed to a model checker). The ones out there (by Fisher et. al. and others) are complex on account have having to deal directly with temporal resolution. So looking for something quick and good enough for now (I'm not too concerned with retaining decidability or its efficiency at this point), I am considering the translation of PLTL into first order logic (FOL). The propositions are turned into unary predicates over numbers. This translation is well known and described in several places (eg Fisher)

p → p(i)

$\circ$p → p(i + 1)

$\diamond$p → ∃j. (j ≥ i) ∧ p(j)

$\Box$p → ∀j. (j ≥ i) ⇒ p(j)

The problem is that these first order formulas have distinguished symbols > and succ (as well as equality) - alternatively the FOL formulas are meant to be interpreted w.r.t. a natural number line which corresponds to the timeline of PLTL. Is there a good way to implement a resolution prover that can take into account or provide these symbols with their required interpretation? More specifically:

• For example, would it work to add the theory of the successor function to the translation and go from there?
• How would I handle equality? (paramodulation?)
• I'd like to be able to implement this in Prolog but you can't encode equational theories like subsets of arithmetic in Prolog, but would Prolog's built-in arithmetic operators perhaps suffice?

Thanks!

• If you translate to FOL, why not try an SMT solver like Z3? – Radu GRIGore Apr 28 '17 at 9:07
• @ Radu: Due to some other constraints, I specifically am looking for a resolution prover. Besides, SMT solvers aren't complete for FOL, they make a best effort for certain fragments of FOL. – S.N. May 1 '17 at 19:53


text:
Browse Questions

# Find a particular solution satisfying the given condition$\large\frac{dy}{dx}$$+2y\tan x=\sin x;\;y=o\;when\;x=\large\frac{\pi}{3} \begin{array}{1 1}(A)\;y = \cos x - 2\cos^2x \\ (B)\;y = \cos x + 2\cos^2x \\ (C)y = \sin x - 2\cos^2x \\(D)\;y = \cos x - 2\sin^2x \end{array} Can you answer this question? ## 1 Answer 0 votes Toolbox: • To solve the first order linear differential equation of the form \large\frac{dy}{dx}$$ + Py = Q$
• (i) Write the given equation in the form of $\large\frac{dy}{dx}$$+ Py = Q • (ii) Find the integrating factor (I.F) = e^{\int Pdx}. • (iii) Write the solution as y(I.F) = integration of Q(I.F) dx + C Step 1: Using the information in the tool box, \large\frac{dy}{dx}$$ +2y\tan x = \sin x$
Here $P = 2\tan x$ and $Q = \sin x$
To find the integral factor
$\int P dx = \int 2\tan xdx$
$\qquad\;\;=2 \log|\sec x|$ or $log|\sec^2x|$
Hence $I.F = e^{\large\log|\sec^2x|} = \sec^2x$
Step 2:
Hence the required solution is $y\sec^2x = \int\sin x(\sec^2x)dx + C$
$\int\sin x(\sec^2x)dx = \int\sec x.\tan x dx = \sec x$
Hence the require solution is $y\sec^2x = \sec x + C$
Step 3:
It is given $y = 0$ and $x = \large\frac{\pi}{3}$
substituting these values to evaluate C
$0.\sec^2(\large\frac{\pi}{3}) =$$\sec(\large\frac{\pi}{3})$$ + C$


text:
• Norihisa Watanabe

Articles written in Pramana – Journal of Physics

• Application of FIRE for the calculation of photon matrix elements

The next-to-next-to-leading order (the order $\alpha \alpha_{s}^{2}$ ) corrections to the first moment of the polarized virtual photon structure function $g_{1}^{\gamma} (x, Q^{2}, P^{2})$ are studied in perturbative QCD for the kinematical region $\Lambda^{2} \ll P^{2} Q^{2}$, where $−Q^{2} (−P^{2})$ is the mass square of the probe (target) photon and 𝛬 is the QCD scale parameter. In order to evaluate the two-loop Feynman diagrams for the photon matrix element of the gluon operator, I apply the recently developed algorithm FIRE which reduces a complicated sum of scalar Feynman integrals to a linear combination of a few master integrals. The details of the calculation are presented.

• # Pramana – Journal of Physics

Volume 96, 2022
All articles
Continuous Article Publishing mode

• # Editorial Note on Continuous Article Publication

Posted on July 25, 2019

Click here for Editorial Note on CAP Mode

© 2021-2022 Indian Academy of Sciences, Bengaluru.


text:
# Try to Solve Without a Calculator 2

Number Theory Level 2

$1045^{2089}-1044^{2089}\equiv x \pmod{2089}$ What is the minimum value of $$x$$, without using a calculator?

×


text:
# mne.time_frequency.psd_welch¶

mne.time_frequency.psd_welch(inst, fmin=0, fmax=inf, tmin=None, tmax=None, n_fft=256, n_overlap=0, n_per_seg=None, picks=None, proj=False, n_jobs=1, reject_by_annotation=True, average='mean', verbose=None)[source]

Compute the power spectral density (PSD) using Welch’s method.

Calculates periodograms for a sliding window over the time dimension, then averages them together for each channel/epoch.

Parameters
instinstance of Epochs or Raw or Evoked

The data for PSD calculation.

fminfloat

Min frequency of interest.

fmaxfloat

Max frequency of interest.

tmin

Min time of interest.

tmax

Max time of interest.

n_fftint

The length of FFT used, must be >= n_per_seg (default: 256). The segments will be zero-padded if n_fft > n_per_seg. If n_per_seg is None, n_fft must be <= number of time points in the data.

n_overlapint

The number of points of overlap between segments. Will be adjusted to be <= n_per_seg. The default value is 0.

n_per_seg

Length of each Welch segment (windowed with a Hamming window). Defaults to None, which sets n_per_seg equal to n_fft.

picks

Channels to include. Slices and lists of integers will be interpreted as channel indices. In lists, channel type strings (e.g., ['meg', 'eeg']) will pick channels of those types, channel name strings (e.g., ['MEG0111', 'MEG2623'] will pick the given channels. Can also be the string values “all” to pick all channels, or “data” to pick data channels. None (default) will pick good data channels(excluding reference MEG channels).

projbool

Apply SSP projection vectors. If inst is ndarray this is not used.

n_jobsint

The number of jobs to run in parallel (default 1). Requires the joblib package.

reject_by_annotationbool

Whether to omit bad segments from the data while computing the PSD. If True, annotated segments with a description that starts with ‘bad’ are omitted. Has no effect if inst is an Epochs or Evoked object. Defaults to True.

New in version 0.15.0.

average

How to average the segments. If mean (default), calculate the arithmetic mean. If median, calculate the median, corrected for its bias relative to the mean. If None, returns the unaggregated segments.

New in version 0.19.0.

verbose

If not None, override default verbose level (see mne.verbose() and Logging documentation for more).

Returns
psdsndarray, shape (…, n_freqs) or (…, n_freqs, n_segments)

The power spectral densities. If average='mean or average='median' and input is of type Raw or Evoked, then psds will be of shape (n_channels, n_freqs); if input is of type Epochs, then psds will be of shape (n_epochs, n_channels, n_freqs). If average=None, the returned array will have an additional dimension corresponding to the unaggregated segments.

freqsndarray, shape (n_freqs,)

The frequencies.

Notes

New in version 0.12.0.


text:
# Cohen Sutherland Line Clipping Algorithm

Computer Graphics / Wednesday, September 25th, 2019

# Cohen Sutherland Line Clipping

Cohen Sutherland Line Clipping algorithm is quite interesting. The clipping problem is simplified by dividing the area surrounding the window region into four segments Up, Down, Left, Right (U, D, L, R) and assignment of number 1 and 0 to respective segments helps in positioning the region surrounding the window. How this positioning of regions is performed can be well understood by considering Figure 1.

In Figure 1 you might have noticed, that all coding of regions U, D, L, R is done with respect to window region. As window is neither Up nor Down, neither Left nor Right, so, the respective bits UDLR are 0000; now see region 1 of Figure 1. The positioning code UDLR is 1010, i.e., the region 1 lying on the position which is upper left side of the window. Thus, region 1 has UDLR code 1010 (Up so U=1, not Down so D=0, Left so L=1, not Right so R=0).

The meaning of the UDLR code to specify the location of region with respect to window is:
1st bit ⇒ Up (U); 2nd bit ⇒ Down (D); 3rd bit ⇒ Left (L); 4th bit ⇒ Right (R)

Now, to perform Line clipping for various line segment which may reside inside the window region fully or partially, or may not even lie in the widow region; we use the tool of logical AND-ing between the UDLR codes of the points lying on the line.

Logical ANDing (^) operation between respective bits implies

1 ^ 1 = 1; 1 ^ 0 = 0; 0 ^ 1 = 0; 0 ^ 0 = 0

Note:

UDLR code of window is 0000 always and w.r.t. this will create bit codes of other regions.

A line segment is visible if both the UDLR codes of the end points of the line segment equal to 0000 i.e. UDLR code of window region. If the resulting code is not 0000 then, that line segment or section of line segment may or may not be visible.
Now, let us study how this clipping algorithm works. For the sake of simplicity we will tackle all the cases with the help of example lines l1 to l5 shown in Figure 2.

Each line segment represents a case.

Note, that in Figure 2, line l1is completely visible, l2 and l3 are completely invisible; l4 and l5 are partially visible. We will discuss these out comings as three separate cases.

Case 1: l1 → completely visible, i.e., Trivial acceptance (both points lie inside the window)
Case 2: l2 and l3 → Invisible, i.e., Trivial acceptance rejection
Case 3: l4 and l5 → partially visible (partially inside the window)

Now, let us examine these three cases with the help of this algorithm:

Case 1: (Trivial acceptance case) if the UDLR bit codes of the end points P, Q of a given line is 0000 then line is completely visible. Here this is the case as the end points a and b of line l1 are: a (0000), b (0000). If this trivial acceptance test is failed then, the line segment PQ is passed onto Case 2.

Case 2: (Trivial Rejection Case) if the logical intersection (AND) of the bit codes of the end points P, Q of the line segment is ≠ 0000 then line segment is not visible or is rejected.

Note that, in Figure 2, line 2 is completely on the top of the window but line 3 is neither on top nor at the in bottom plus, either on the LHS nor on the RHS of the window. We use the standard formula of logical ANDing to test the non visibility of the line segment.

So, to test the visibility of line 2 and 3 we need to calculate the logical intersection of end points for line 2 and line 3.

line l2:  bit code of end points are 1010 and 1000 logical intersection of end points = (1010) ^ (1000) = 1000 as logical intersection ” 0000. So line 2 will be invisible.

line l3: end points have bit codes  0010 and 0101 now logical intersection = 0000, i.e., 0010 ^ 0101 = 0000 from the Figure 2, the line is invisible. Similarly in line 4 one end point is on top and the other on the bottom so, logical intersection is 0000 but then it is partially visible, same is true with line 5. These are special cases and we will discuss them in case 3.

Case 3: Suppose for the line segment PQ, both the trivial acceptance and rejection tests failed (i.e., Case 1 and Case 2 conditions do not hold, this is the case for l3, l4 and l5 line segments) shown above in Figure 3. For such non-trivial

Cases the Cohen Sutherland line clipping algorithm is processed, as follows

Since, both the bitcodes for the end points P, Q of the line segment cannot be equal to 0000. Let us assume that the starting point of the line segment is P whose bit code is not equal to 0000. For example, for the line segment l we choose P to be the bitcodes 1001. Now, scan the bitcode of P from the first bit to the fourth bit and find the position of the bit at which the bit value 1 appears at the first time. For the line segment l5 it appears at the very first position.

If the bit value 1 occurs at the first position then proceed to intersect the line segment with the UP edge of the window and assign the first bit value to its point of intersection as 0. Similarly, if the bit value 1 occurs at the second position while scanning the bit values at the first time then intersect the line segment PQ with the Down edge of the window and so on. This point of intersection may be labeled as P’. Clearly the line segment PP’ is outside the window and therefore rejected and the new line segment considered for dipping will be P’Q. The coordinates of P’ and its remaining new bit values are computed. Now, by taking P as P’, again we have the new line segment PQ which will again be to Case 1 for clipping.

Geometrical study of the above type of clipping (it helps to find point of intersection of line PQ with any edge).

Let (x1, y1 ) and (x2 , y2) be the coordinates of P and Q respectively.

Top case /above case:
If y1 > ywmax then 1st bit of bit code = 1 (signifying above) else bit code = 0

Bottom case / below case:
If y1 < ywmin then 2nd bit = 1 (i.e. below) else bit = 0

Left case:
If x1 < xwmin then 3rd bit = 1 (i.e. left) else bit = 0

Right case:
If x1 > xwmax then 4th bit = 1 (i.e. right) else bit = 0

To learn about another line clipping algorithm: Cyrus-Back Algorithm Visit the link

## Limitations of Cohen-Sutherland clipping algorithm

1) Clipping window region can be rectangular in shape only and no other polygonal shaped window is allowed.

2) Edges of rectangular shaped clipping window has to be parallel to the x-axis and y-axis.

3) If end points of line segment lies in the extreme limits i.e., one at R.H.S other at L.H.S., and on one the at top and other at the bottom (diagonally) then, even if the line doesn’t pass through the clipping region it will have logical intersection of 0000 implying that line segment will be clipped but infect it is not so.

## Cohen-Sutherland line clipping algorithm implementation in C

#include<stdio.h>
#include<graphics.h>
#include<conio.h>

typedef unsigned int outcode;
enum { TOP=0x1, BOTTOM=0x2, RIGHT=0x4, LEFT=0x8 };

void lineclip(x0,y0,x1,y1,xwmin,ywmin,xwmax,ywmax )
float x0,y0,x1,y1,xwmin,ywmin,xwmax,ywmax;
{

int gd,gm;
outcode code0,code1,codeout;
int accept = 0, done=0;

code0 = calcode(x0,y0,xwmin,ywmin,xwmax,ywmax);
code1 = calcode(x1,y1,xwmin,ywmin,xwmax,ywmax);

do{
if(!(code0 | code1))
{ accept =1 ; done =1; }
else
if(code0 & code1) done = 1;
else
{
float x,y;
codeout = code0 ? code0 : code1;
if(codeout & TOP)
{
x = x0 + (x1-x0)*(ywmax-y0)/(y1-y0);
y = ywmax;
}
else
if( codeout & BOTTOM)
{
x = x0 + (x1-x0)*(ywmin-y0)/(y1-y0);
y = ywmin;
}
else
if ( codeout & RIGHT)
{
y = y0+(y1-y0)*(xwmax-x0)/(x1-x0);
x = xwmax;
}
else
{
y = y0 + (y1-y0)*(xwmin-x0)/(x1-x0);
x = xwmin;
}
if( codeout == code0)
{
x0 = x; y0 = y;
code0=calcode(x0,y0,xwmin,ywmin,xwmax,ywmax);
}
else
{
x1 = x; y1 = y;
code1 = calcode(x1,y1,xwmin,ywmin,xwmax,ywmax);
}
}
} while( done == 0);

if(accept) line(x0,y0,x1,y1);

rectangle(xwmin,ywmin,xwmax,ywmax);

getch();

}

int calcode (x,y,xwmin,ywmin,xwmax,ywmax)
float x,y,xwmin,ywmin,xwmax,ywmax;
{
int code =0;

if(y> ywmax)
code |=TOP;
else if( y<ywmin)
code |= BOTTOM;
else if(x > xwmax)
code |= RIGHT;
else if ( x< xwmin)
code |= LEFT;

return(code);
}

main()
{

float x2,y2,x1,y1,xwmin,ywmin,xwmax,ywmax;
int gd=DETECT,gm;

clrscr();
initgraph(&gd,&gm,"e:\\tc\\bgi");

printf("\n\n\tEnter the co-ordinates of Line :");

printf("\n\n\tX1 Y1 : ");
scanf("%f %f",&x1,&y1);

printf("\n\n\tX2 Y2 : ");
scanf("%f %f",&x2,&y2);

printf("\n\tEnter the co_ordinates of window :\n ");
printf("\n\txwmin , ywmin : ");
scanf("%f %f",&xwmin,&ywmin);
printf("\n\txwmax , ywmax : ");
scanf("%f %f",&xwmax,&ywmax);
clrscr();
line(x1,y1,x2,y2);
rectangle(xwmin,ywmin,xwmax,ywmax);
getch();
clrscr();

lineclip(x1,y1,x2,y2,xwmin,ywmin,xwmax,ywmax );
getch();
closegraph();

}

<< Previous   Next>>

;


text:
# [X] File Name Case Conversion

I have noticed that lately, the command I created to change the filename to all Uppercase text and Lowercase extension is not working for all the files. It used to work perfectly a couple updates back (not sure what update number).

Has anyone else encountered this issue?

Could you show us the function (command) with which you rename the files?
Also, could you show us the original filename and the result that you expected and that you got?
Also, please tell us which filesystem you use.
Otherwise it is a little hard to see if there is an issue.

1 Like

The Action I have used is: Case conversion "FILENAME": UPPER case

When I select all entries and run the action most of the files will have been edited, but not all when I look in the file folder.

Eg: Bruno Mars - 24Karrat.mp3 would change to BRUNO MARS - 24KARRAT.mp3 but this is not happening to all the files.

running Windows 10.

To me it looks ok.
The exceptions would be interesting.
It could also be that some of the files are write protected or that you are not the owner.
Or that you have entered a couple of characters to define the word borders.

Just guessing, as I do not use it: maybe it is the case of the Library feature not upgrading the case of letters?

Contrary to what is written above, I'm assuming that you've used _FILENAME (instead of FILENAME) for the case conversion action.

yes. that was a typo. _FILENAME is the field used in the action.

OK.
And now for the missing information:

Not sure what missing information you are looking for?

I use the action command to make the Filename all capitals. It shows that it did it in the Mp3Tag program, but when I go to the file folder where the files are, the file name did not change to all capital letters?

Here is a video of what I am talking about.

https://photos.app.goo.gl/Z0jU3tiNB7sooGVD3

Thank you for the effort to create a video - but sorry, I cannot decipher anything that happens.
I can see that folders are opened and a file gets treated with an action, probably "Case conversion", then a message box appears telling that something has happened - just don't ask me what.
I just tried to rename a file
Action of the type "Case conversion"
Field: _FILENAME
Conversion: CAPITALS
Word starting after:
(left empty)

Filename before the conversion:
Ambient Diary.one _ 101 _ Babel _ The Return Of Babel.mp3
Filename after the conversion:
AMBIENT DIARY.ONE _ 101 _ BABEL _ THE RETURN OF BABEL,mp3
I would say that this worked as expected.
I copied the filenames from the explorer, so even that shows the files as intended.

What is different to your approach?

Thanks for the video. I can see that the case conversion fails at
Big Sean & Metro Boomin ft. Kash Doll - So Good.mp3

Can you go to Windows Explorer and copy the file name here (via F2 and Ctrl+C) just for me to see if there are some special characters involved.

Can you also give some details about the filesystem that is used on you E: (SHARED) drive? Is it normal NTFS or something else?

This is the file name copied.

Big Sean & Metro Boomin ft. Kash Doll - So Good

The Drive is formatted as FAT32. Its been the same drive used for a few years and with MP3Tag for many years which used to preform the action using _FILENAME command with no issues.

As you saw in the video, some of the files in the folder did change when using the action with the _FILENAME command. I usually highlight all the tracks in the MP3Tag list and apply the action for the conversion. Just some change, and some do not change. Very weird.

Applying an action of the type "Case conversion" leads to:
BIG SEAN & METRO BOOMIN FT. KASH DOLL - SO GOOD.mp3
Does renaming on a different storage medium work?

I think the magic word here is "FAT32". Fat32 knows no access rights.

And FAT32 is case-insensitive, other than NTFS, wich is case-sensitive.
To my knowledge it is not possible to change the writing of a file on FAT32 from lower-case to upper-case or the other way round. To do so you have to change at least something else of the filename to make a change of the case happen.

When you execute an case-conversion action of FAT32-file with MP3Tag, MP3Tag shows the expected result and the conversion, because it obviously does not pay attention to the case-sensivity of the file-system.
If you then reread the files with MP3Tag it shows again in the former case.

If this is a bug of MP3Tag?
I don't know. Perhaps it should not show a wrong result of the action if in fact there were no changes possible because of a FAT32-Drive. To change this behaviour could be a bit tricky because is is only relevant for case-changes without renaming.

1 Like

FAT32 is case-insensitive but case-preserving, which basically means that you can change casing of filenames.

I've just tried renaming of files with a USB drive formatted with FAT32 and it worked without problems.

• After the failed renaming and closing of Mp3tag, what are the contents of %APPDATA\Mp3tag\Mp3tagError.log

• Are there any other programs accessing the file at the time of renaming?
You can check with Microsoft/SysInternals Process Explorer
Go to Find > Find Handle or DLL. In the Handle or DLL substring text box, type the path to the file (e.g. E:\path\to\file.mp3) and click Search. All processes which have an open handle to that file should be listed.

Before I wrote in this thread I tried it too and it did not work with MP3Tag.
Using an action format value or the converter Tag -> Filename or simply the case-conversion for the filename does not change anything if the filename stays the same inspite of case-conversion.

That is why I started this topic because it used to work all the time.

• The contents of the error log were;

================================================================================
Mp3tag v2.86 - 07.03.2018 - 20:09:08
--------------------------------------------------------------------------------"
OS-Version: Windows 10, 64-bit
--------------------------------------------------------------------------------"
Build: Jan 24 2018 09:10:25
--------------------------------------------------------------------------------"
AppPath: 363.950.649.344 Bytes frei (C:\Program Files (x86)\Mp3tag)
DataPath: 363.950.649.344 Bytes frei (C:\Users\VazMain\AppData\Roaming\Mp3tag\data)
TempPath: 363.950.649.344 Bytes frei (C:\Users\VazMain\AppData\Local\Temp\Mp3tag v2.86)
==============================================================================="

• There were no other programs accessing the file at the time.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.


text:
# Rule of 72 Calculator

## How to calculate the Rule of 72

The Rule of 72 is a way to calculate the amount of time that it will take for an investment to double in value for different interest rates.

The rule of 72 takes into account compounding of interest, so if you have an investment that is $100 and you are getting 10% interest, then after one year you will have$110. In the second year, your interest will be on the $110, giving you$11 of interest, meaning you will have \$121. This goes on and on.

### Formula for the Rule of 72

$years = {72 \over interestRate}$


text:
Question
(a) By how many percent is the torque of a motor decreased if its permanent magnets lose 5.0% of their strength? (b) How many percent would the current need to be increased to return the torque to original values?
1. $-5.00\%$
2. $+5.26\%$
Solution Video


text:
# Sequential Optimization and Reliability Assessment (SORA)

A reliability-based design optimization method. Reliability-based design optimization (RBDO) methods take uncertainties in the design into account and search for designs that satisfy the design requirements with a required probability of success.

A reliability-based design problem is formulated as:
Objective
min f(x, r, p)
Constraints
P(g(x, r, p ≤ 0.0) > PS
where,
x
Deterministic input variables
r
Random input variables (affect the design but are subject to uncertainties)
p
Pure random parameters (variables we have no control over but affect the design, such as humidity and temperature)

## Usability Characteristics

• An extension of Sequential Optimization and Reliability Assessment is implemented in HyperStudy to allow for robust design optimization. Robust design optimization attempts to minimize the objective variance in order to reduce its sensitivity to design variations and consequently increase the design's robustness. The implementation in HyperStudy is based on the use of percentiles for the objective function and is turned on via the Robust Optimization setting in the Specification step.
• Sequential Optimization and Reliability Assessment is the most accurate of the three RBDO methods available in HyperStudy. It is also the most expensive.
• Sequential Optimization and Reliability Assessment terminates if one of the conditions below are met:
• One of the two convergence criterias are met.
• The absolute objective change is less than a convergence tolerance value (Termination Criteria) and there is no constraint violation (Constraint Violation Tol. (%)).
• The relative objective change is less than a convergence tolerance value (Termination Criteria) and there is no constraint violation (Constraint Violation Tol. (%)) in the last design.
• The maximum number of allowable iterations (Maximum Iterations) is reached.
An exception is when the current objective is worse than the previous objective and the constraint violation of the previous design is within allowable violation. When this occurs, Sequential Optimization and Reliability Assessment will be terminated.
• The reliability analysis is carried out by searching for the most probable point (MPP). Issues such as non-uniqueness of the MPP and highly non-linear output response functions can reduce the accuracy of the reliability calculation.
• The number of evaluations in each iteration is automatically set and varies due to the finite difference calculations used in the sensitivity calculation. The number of evaluations in each iteration is dependent of the number of variables. The evaluations required for the finite difference are executed in parallel. The evaluations required for the line search are executed sequentially.

## Settings

In the Specifications step, change method settings from the Settings and More tabs.
Note: For most applications the default settings work optimally, and you may only need to change the Maximum Iterations and Robust Optimization.
Table 1. Settings Tab
Parameter Default Range Description
Maximum Iterations 25 > 0 Maximum number of iterations allowed.
Robust Optimization No No or Yes
Defines whether this is a robust optimization or not.
No
Do not use robust optimization.
Yes
Use robust optimization.
Robust Min % 95.0
• > 50
• < 100
Defines the percentile value of robust optimization for minimization objective.
Robust Max % 5.0
• > 0
• < 50
Defines the percentile value of robust optimization for maximization objective.
On Failed Evaluation Terminate optimization
• Terminate optimization
• Ignore failed evaluations
Terminate optimization
Terminates with an error message when an analysis run fails.
Ignore failed evaluations
Ignores the failed analysis run.
Table 2. More Tab
Parameter Default Range Description
Angle Convergence Tol. 0.25 > 0.0
Angle convergence tolerance for inverse MPP search, in unit of degrees. If the angle between the vector of $\overline{u}$ (design point in standard normal distribution space) and the negative gradient falls within the tolerance, then inverse MPP search is regarded as converged.
Tip: A smaller value favors a higher precision of reliability analysis, but more computational effort is needed.
Termination Criteria 1.0e-4 > 0.0 Termination tolerance.
If the absolute or relative change of the objective value is less than this value, and the constraint violation is not larger than this value, then Sequential Optimization and Reliability Assessment will be terminated. There also must not be any constraint with an allowable violation that has been exceeded in the last design.
Where, $f$ is the objective; $k$ is the current iteration number; ${c}_{\mathrm{max}}$ is the maximum constraint violation; ${g}_{\mathrm{max}}$ is the allowable constraint violation; Termination Criteria is the value of the termination criteria.
An exception is when the current objective is worse than the previous objective and the constraint violation of the previous design is within allowable violation, Sequential Optimization and Reliability Assessment will be terminated.


text:
# A simple Neural Network, finding weights to achieve 100% accuracy

So I've been watching lectures and doing the problem sheets from the class CS 229 2017, taught at Stanford by Andrew Ng. In problem sheet 3 he puts forward the following question:

$\textbf{So this is what I did in part a)}$

What we have is:

$\sigma(z) = \frac{1}{1+e^{-z}}$ and it's derivative is $\sigma'(z)=\sigma(z)(1-\sigma(z))$

$l=\frac{1}{n} \sum^{n}_{i=1} (o^{i}-y^{i})^2$

From this we can calculate:

$\textbf{Then for part b)}$ Here I'm completely lost. I'm guessing the triangle that he talks about is the following:

However, I don't understand how I would choose the weights in such a way that I would achieve 100% accuracy. Any help or hint would be very well appreciated!

• The first hidden neuron will represent $x_1 > 0.5$
• The second will represent $x_2 > 0.5$
• The third will represent $x_1 + x_2 < 1$
• The straight lines aren't exactly caused by the sigmoid function. They come from the weights: an equation like ax_1 + bx_2 + c = 0 represents a straight line, and this weighted sum is exactly the input to the sigmoid functions. – Greg d'Eon Mar 29 '18 at 20:39