Does anyone know how to increase legend font-size in octave?
Not sure if this was a solution when the OP was submitted, but this is pretty easy now:
h = legend({"foo","bar"});
set (h, "fontsize", 16);
This worked for me (kubuntu 9.04, octave 3.2.2)
print("plot.eps","-deps", "-F:30")
This forces all text elements in figure to be printed with font size 30. See also octave function: print.
Based on another Posting on Stackoverflow I found the following solution.
copied_legend = findobj(gcf(),"type","axes","Tag","legend");
set(copied_legend, "FontSize", FontSize);
GNU Octave, version 3.6.3
Matlab: How to obtain all the axes handles in a figure handle?
Get axis object handle and set 'fontsize' property (octave 3.2.4):
ax = gca();
set(ax, 'fontsize', 15);
Try the following:
'{\fontsize{12} legend1-text}'
Where you have to include it for every legend text. My command, that actually worked, was:
legend('{\fontsize{10} Low }', '{\fontsize{10} Medium }', '{\fontsize{10} High }')
Related
I want to compare two smoothing methods for a bigram model:
Add-one smoothing
Interpolated Absolute Discounting
For the first method, I found some codes.
def calculate_bigram_probabilty(self, previous_word, word):
bigram_word_probability_numerator = self.bigram_frequencies.get((previous_word, word), 0)
bigram_word_probability_denominator = self.unigram_frequencies.get(previous_word, 0)
if self.smoothing:
bigram_word_probability_numerator += 1
bigram_word_probability_denominator += self.unique__bigram_words
return 0.0 if bigram_word_probability_numerator == 0 or bigram_word_probability_denominator == 0 else float(
bigram_word_probability_numerator) / float(bigram_word_probability_denominator)
However, I found nothing for the second method except for some references for 'KneserNeyProbDist'. However, this is for trigrams!
How can I change my code above to calculate it? The parameters of this method must be estimated from a development-set.
In this answer I just clear up a few things that I just found about your problem, but I can't provide a coded solution.
with KneserNeyProbDist you seem to refer to a python implementation of that problem: https://kite.com/python/docs/nltk.probability.KneserNeyProbDist
There exists an article about Kneser–Ney smoothing on wikipedia: https://en.wikipedia.org/wiki/Kneser%E2%80%93Ney_smoothing
The article above links this tutorial: https://nlp.stanford.edu/~wcmac/papers/20050421-smoothing-tutorial.pdf but this has a small fault on the most important page 29, the clear text is this:
Modified Kneser-Ney
Chen and Goodman introduced modified Kneser-Ney:
Interpolation is used instead of backoff. Uses a separate discount for one- and two-counts instead of a single discount for all counts. Estimates discounts on held-out data instead of using a formula
based on training counts.
Experiments show all three modifications improve performance.
Modified Kneser-Ney consistently had best performance.
Regrettable the modified Version is not explained in that document.
The original documentation by Chen & Goodman luckily is available, the Modified Kneser–Ney smoothing is explained on page 370 of this document: http://u.cs.biu.ac.il/~yogo/courses/mt2013/papers/chen-goodman-99.pdf.
I copy the most important text and formula here as screenshot:
So the Modified Kneser–Ney smoothing now is known and seems being the best solution, just translating the description beside formula in running code is still one step to do.
It might be helpful that below the shown text (above in screenshot) in the original linked document is still some explanation that might help to understand the raw description.
I was wondering whether it is possible to change the rate at which a lights intensity decareases over distance.
something like this:
So I finally figuered it out.
You have to write a custom shader that is essetially the same as the default one, but change the line that takes care of the interpolation:
"v_color = s*quad_colors;\n"
for example:
"v_color = s*2*quad_colors;\n"
halves the dropoff rate, while:
"v_color = (s*0)+quad_colors;\n"
gets rid of any blur (leaving out the "s" completely out won't work)
I have the "v_color = squad_colors;\n" its in the vertex shader of the light source. See https://github.com/libgdx/box2dlights/blob/master/src/shaders/LightShader.java. However the above didn't work for me, the number you use must be a float. E.g."v_color = (s0.0)+quad_colors;\n"
I been trying to research it a bit and this may be frowned upon, but I don't want to learn how to do everything in VB since I'm just doing what should be a 5-10 minute program to make something a little easier for myself. So sorry for that in advance.
Anyways, I just want to add colors or any formatting really to make stuff easier to read or the like. I originally was doing textboxes with the read only attribute and found you couldn't add good formatting with it. Label was similar in terms you could add one color a label. RichTextBox was the next idea and while it works, it seems like quite a bit of work for what I'm needing.
I just want an idea on how to make a single form have a font like "these three words"
It's super easy with bbcone and html, and I can't imagine the best way in VB is something that takes around 10 lines for one string of text.
Thanks.
Like you don't want to learn how to, but have notions of Html, then I think that the best solution for your needs is to use this 3rd party user-control, Html Renderer, which can render html/css code.
Another approach is to use a WebBrowser as mentioned in the comments, however, it will be (very)slower, or also you can use the MSHTML ocx which Microsoft specified that is more focused to document renderization tasks, but is harder to use than the specified user-control because you will need to investigate for the online documentation and usage of the MSHTML members, and seems that you don't want to do, since you specified that a RichTextBox has too much effort for your needs.
I have a richtextbox1 which has some text in it - I use the code below to search through the text and change specific words to a different font/style and color :-
DIM TZZ as String
TZZ = RichTextBox1.Text
TZZ = UCase(TZZ)
Dim x As Single
For X = 1 To Len(TZZ)
Dim y As Single = InStr(TZZ, "CHANGES MADE")
If y > 0 Then
Dim intLength As Integer = 12
'select the text
RichTextBox1.Select(y - 1, intLength)
RichTextBox1.SelectionFont = New System.Drawing.Font("Tahoma", 10, FontStyle.Bold Or FontStyle.Italic)
RichTextBox1.SelectionColor = Color.Red
Mid(TZZ, y, 12) = "123456789012"
X = y
End If
Next X
RichTextBox1.Select(0, 0)
I am currently trying to simulate ballistics on an object, that is otherwise not affected by physics. To be precise, I have a rocket-like projectile, that is following an parabolic arc from origin to target with a Lerp. To make it more realistic, I want it not to move at constant speed, but to slow down towards the climax and speed up on its way back down.
I have used the Mathf.Smoothstep function to do the exact opposite of what i need on other objects, i.e. easing in and out of the motion.
So my question is: How do I get an inverted Smoothstep?
I found out that what i would need is actually the inverted formula to smoothstep [ x * x*(3 - 2*x) ], but being not exactly a math genius, I have no idea how to do that. All I got from online calculators was some pretty massive new function, which I'm afraid would not be very efficient.
So maybe there is a function that comes close to an inverted smoothstep, but isn't as complex to compute.
Any help on this would be much appreciated
Thanks in advance,
Tux
Correct formula is available here:
https://www.shadertoy.com/view/MsSBRh
Solution by Inigo Quilez and TinyTexel
Flt SmoothCubeInv(Flt y)
{
if(y<=0)return 0;
if(y>=1)return 1;
return 0.5f-Sin(asinf(1-2*y)/3);
}
I had a similar problem. For me, mirroring the curve in y = x worked:
So an implementation example would be:
float Smooth(float x) {
return x + (x - (x * x * (3.0f - 2.0f * x)));
}
This function has no clamping, so that may have to be added if x can go outside the 0 to 1 interval.
Wolfram Alpha example
If you're moving transforms, it is often a good idea to user iTween or similar animation libraries instead of controlling animation yourself. They have a an easy API and you can set up easing mode too.
But if you need this as a math function, you can use something like this:
y = 0.5 + (x > 0.5 ? 1 : -1) * Mathf.Pow(Mathf.Abs(2x - 1),p)/2
Where p is the measure of steepness that you want. Here's how it looks:
You seem to want a regular parabola. See the graph of this function:
http://www.wolframalpha.com/input/?i=-%28x%2A2-1%29%5E2%2B1
Which is the graph that seems to do what you want: -(x*2-1)^2+1
It goes from y=0 to y=1 and then back again between x=0 and x=1, staying a bit at the top around x=0.5 . It's what you want, if I understood it correctly.
Other ways to write this function, according to wolfram alpha, would be -(4*(x-1)*x) and (4-4*x)*x
Hope it helps.
That i want to do is to delete certain rows (or columns doesn't really mater...) from a given vector.
By going through Simulink's components found out that there is nothing performing such an operation,there are blocks help one add elements but nothing clearly for removing,so ended up trying to delete them by using a function block and following the online examples that demonstrate the usage of "[]".Lets say that i want to delete the second column of the vector u,i do u(:, 2) = [];.
That works absolutely fine in a separate m file or function but unfortunately not in a function block returning:
"Simulink does not have enough information to determine output sizes for
this block. If you think the errors below are inaccurate, try specifying
types for the block inputs and/or sizes for the block outputs."
and:
Size mismatch (size [4 x 4] ~= size [4 x 3]).
The size to the left is the size of the left-hand side of the assignment.
Function 'MATLAB Function' (#107.41.42), line 4, column 1:
"u"
Launch diagnostic report.
Is there any alternative you can suggest to remove several elements in a given vector in Simulink?
Thanks in advance
George
Finally,managed to do it without function block.There is a much easier way,by using Pad,and defining the output vector to be shorter than the input resulting in truncation.