Octave-online.net vpa((pi-1),100) strange result? - octave

in octave-online.net the vpa() function returns me the non precise result. If i try some computation with a lot digits behind decimal after 49's digit is the result zero. Is there some trick how to compute with a lot digits behind decimal?
vpa((pi-1),100)
returns:
2.141592653589793115997963468544185161590576171875000000000000000000000000000000000000000000000000000
I have similar problem for similar inputs with different length(e.g. vpa((113/111),100))
Thank You.
trying:
vpa((pi-1),100)
expecting:
2.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068

With vpa((p-1),100) the calculation of pi-1 is done using limited precision and the (imprecise) result is then applied to the vpa function.
Instead, the vpa function needs to make the calculation:
vpa('pi-1',100)
giving the expected result:
2.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068
See more details on the vpa reference page.

Related

How can I use "Interpolated Absolute Discounting" for a bigram model in language modeling?

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.

Split number into expression

I have this expression:
=IIF(ISNOTHING(code.dividir((Sum(Fields!PPMS_PPM.Value,"DS_DataPPMsDosAniosAnterior")
* 1000000),Sum(Fields!PPMBSC_VentasPPM.Value,"DS_DataPPMsDosAniosAnterior"))),0,
code.dividir((Sum(Fields!PPMS_PPM.Value,"DS_DataPPMsDosAniosAnterior") * 1000000),
Sum(Fields!PPMBSC_VentasPPM.Value,"DS_DataPPMsDosAniosAnterior")))
Result of that is a number like: 32.3637282716252, how can I do to get only 32 plus 2 decimal numbers like 32.36 Regards
Pepe.. I feel these questions are pretty simple to solve if you just google it.. instead of asking such questions here..
but here is how it can be done anyway..
Right click on the text box that has this expression, properties -> formatting -> Number and then choose 2 decimal places. Done.

Javascript working with empty cells

I am working with Google Sheets. I want to build a custom function that adds 5 cells together. This code worked just fine:
function addData(a,b,c,d,e){
return a+b+c+d+e
}
When I put the values: 80,80,80,80,80...I appropriately get 400.
The problem happens when one of the cells in empty. When I have the values:
___,80,80,80,80 I get 80808080
80,___,80,80,80 I get 808080
80,80,___,80,80 I get 16080
80,80,80,___,80 I get 24080
80,80,80,80,___ I get 320 <--- correct answer
The function appears to add correctly until it hits an empty cell and then just tacks on the remaining values instead of continuing to add them.
I am very new to JavaScripting so I really do not know where to begin my research. Any help would be greatly appreciated. I asked this question before but I feel like this is more concise as to what I am trying to accomplish.
you get different results because each column has different format
try to convert string type to integer
or let script like that and change the column format to number
function addData(a,b,c,d,e){
return parseInt(a)+parseInt(b) +parseInt(c) +parseInt(d) +parseInt(e)
}

Q format of forward FFT of fixed version of KISS FFT

I have some question about fixed version kiss_fft's butterfly computation.
in "kf_bfly2", input divide by 2 use "C_FIXDIV",
in "kf_bfly3", input divide by 3 use "C_FIXDIV",
in "kf_bfly4", input divide by 4 use "C_FIXDIV",
in "kf_bfly5", input divide by 5 use "C_FIXDIV",
in "kiss_fftr" also use "C_FIXDIV",from the point of view of FFT algorithm,it's no use, It seems using "C_FIXDIV" just to prevent overflow.
but if the input is Q15, what's the output Q value?
the output Q value is consistent with input's?
whether the output magnitude is smaller than the expected?
I'm really puzzled.

how to solve SSRS Formatting issue?

Currently the data in field is coming like this 9646.88 and my requirement is
Remove decimal places and add comma for thousands e.g. 9,646
=IIF((RTRIM(Fields!COMPANY_NAME.Value))="VACANT","",Fields!BASE_RENT_PM.Value)
Please help, I am a newbie in SSRS.
Go to Properties pane when you select the textbox.
Then put this on Format property
#,0;(#,0)
Using Common Functions such as Text and Conversion functions shown in Expression window will give you the desired result.
For e.g,
Format(Int(9646.88), "#,###") // try "#,##0" which returns 0 if less than 1
where Int(9646.88) returns the integer portion of the number 9646 and Format(9646,"#,###") returns a string formatted according to instructions contained in a format String expression "#,###" which is a thousand seperator. Thus, it will give you "9,646".
So, in your case, try this,
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT", "", Format(Int(Fields!BASE_RENT_PM.Value),"#,###"))
Note:
Format(9646.88, "#,###") will return a rounded result 9,647 and
Format("VACANT", "#,###") returns just "#,###",
none of which may not be your desired result.
Have your Tried this?
=FORMAT(IIF((RTRIM(Fields!COMPANY_NAME.Value))="VACANT","",Fields!BASE_RENT_PM.Value),"#,###")
Should solve your issue.
Kind Regards
To add comma for thousands, you need to change your expression.
If you need output as 9,646 then try below.
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT","",Format(Convert.ToInt32(Int(Fields!BASE_RENT_PM.Value),"#,0;(#,0)")))
OR
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT","",Format(CInt(Int(Fields!BASE_RENT_PM.Value),"#,0;(#,0)")))
Updated Answer:
As you want to handle null values as well I would suggest below way to achieve your goal.
Set Textbox visibility with below expression.
=IIF(ISNOTHING(Fields!BA‌​‌​‌​SE_RENT_PM.Value),True,False)
So if null value is there then it will show blank in the ssrs report.