How to calculate Noncentral t-distribution - math.net

Using MathDotNet, which class would I use to calculate a Non Central T-Distribution?
I'm guessing the Student T class but can't workout the parameter required.
Thanks

Related

What design pattern would I use to pass one user choice to all classes where inheritance doesn't seem appropriate?

I am building a Python application which calculates sales, stock available and parts required which first asks a user to choose their department from a combobox.
What design should I use to best inform all classes within the application of the choice of department? Once the department is chosen it remains used throughout the application and for the lifecycle of the application instance.
class Sales:
def __init__(self, departmentname):
self.departmentname = departmentname
self.conn = pyodbc.connect(jsonhandler.get_json('connections.json'))
def calculate_sales(self):
with self.conn:
departmentsalesvalues = pd.read_sql_query(f"""SELECT productcode, quantity, salesprice
FROM salestable
WHERE department = ?""", self.conn,
params=(self.departmentname))
return departmentsalesvalues
This works but it seems clumsy/a poor design. I believe I am missing a concept/pattern which would be useful in all programming languages. Can someone point me in the right direction please?
The questions I have asked myself:
Should I create a Department class? But because the department is not similar to the other classes in any way inheritance seems to be out of the question.
Should I pass this information around in a Main/App class? (Which is what i am currently doing.)
Should I have an 'orchestrator' class which interfaces with the Main/App class?
I am quite new to building scalable applications but I find this sort of design question occurring more and more in my projects.
For a variable that is used everywhere and for the life of the application I see two ways that will accomplish the task.
A) Create a global variable (I know.. globals variables are bad. But for this particular scenario, when all you need is the department and you need it everywhere, a global variable is better than rewriting all of your classes to accept a constructor value)
B) Create a 'Context' class that has the department choice as a variable. The context item gets passed to all of your functions when they are called and you can add more information to the context class if need be.
For scalable applications, you would store this information in a 'configuration' file or in a special table in the database.
You would then have context and middleware.
Context is a dictionary that is passed to all of your business functions.
Middleware is a list of classes that alter the context in some way.
You would have a middleware class called "UserChoices" that has a function:
def alterContext(context={}):
context["DepartmentChoice"] = readDBvalue()
return context
Then you would get the context like so
def getContext():
context ={}
for m in middlewares:
context = m(context)
return context
And then you can use your business functions like so
def businessFunc(context):
return stuff
businessFunc(getContext())

Nested Classes in Python 3

I am trying to create a nested class to perform sum or multiplication of the arguments passed in each subclass.
The below example helps me perform action within the class, however I am unable to find any documentation which would help me with inheriting the attributes from the Parent Class to child.
Recently I came across an article which highlights "nested classes can't access any members of their outer classes at compile-time.". Is there a better way to pass the values between Classes? I tried using global variables, but would like to avoid setting many global variables while I scale this logic to extract my entire datacenter's inventory, perform some calculations and again pass to another class.
class Class1:
firstnumber=0
def __init__(self,arg):
self.firstnumber=arg
class Class2:
def __init__(self,arg):
self.secondnumber=arg
def sumit(self):
return Class1.firstnumber+Class1.Class2.secondnumber
print(Class1(5).firstnumber)
print(Class1(6).Class2(4).secondnumber)
print(Class1(4).Class2(10).sumit())
I would like to perform calculations with
Class1(variable1).Class2(variable2).Class3(variable3).sum() or
Class1(variable1).Class2(variable2).Class3(variable3).multiple() and eventually be able to do following
Datacenter('DC1').GetServer('ServerName').GetStorageCapacity('NFS').Used()
Datacenter('DC1').GetServer('ServerName').GetStorageCapacity('NFS').Free()
http://momentaryfascinations.com/programming/bound.inner.classes.for.python.html
i may be wrong but to my understanding anything you put in between the class() and the init statement is permanent and unchangable. you shouldn't need to create seperate classes for each number. create different instances of the same class.
class numbers:
def __init__(self,arg):
self.arg = arg
c1 = numbers(3)
c2 = numbers(5)
i don't know how you would add the arg variables together maybe someone else can fill in what i'm missing.

django model add default columns

I have to following model:
class publication_type(models.Model):
name = models.CharField(max_length=200)
description = models.TextField(blank=True,null=True,default=None)
And I would like to add a few "default" entrys to this model, that I can always refer to without assuming whether they exist yet or not, for example:
publication_type.objects.create(id=1,name="article",description="...")
Where would be the best position in the django code to position to put this code?

How To sum multiple fields in Acumatica (pxformula)

I know pxformula could do it, but pxformula only accepts two argument parameters. how can i add (sum) multiple fields of the same DAC? can i nest it?
thanks. some working examples would be appreciated, some other methods would also be appreciated.
As suggested in another answer, PXFormula can be used to perform a multi field calculation. However, PXFormula always assigns calculated value to the field it decorates.
PXUnboundFormulaAttribute might be a better approach in case you don't need to store calculated value in any field:
[PXUnboundFormulaAttribute(typeof(Switch<Case<Where<GLTranDoc.debitAccountID, IsNotNull>, GLTranDoc.curyTranTotal>, Sub<GLTranDoc.curyTaxAmt, GLTranDoc.curyInclTaxAmt>>),
typeof(SumCalc<GLDocBatch.curyDebitTotal>))]
For additional examples on the PXUnboundFormulaAttribute, please check Example 7.3: Adding Conditional Calculation of Aggregated Values in the T200 developer class guide at Acumatica University or Acumatica Open University
I know this post is old, but I have been stuck on this for a while. I finally found a simple solution using [PXFormula] by nesting ADD's.
I had made a new grid screen and I wanted the final column to total all the other columns.
MY DAC’s :
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve
The solution:
[PXFormula(typeof(Add<Add<Add<Add<Add<Add<one, two>,
Add<three, four>>, Add<five, six>>, Add<seven, eight>>,
Add<nine, ten>>, Add < eleven, twelve >>), typeof(SumCalc<total>))]
[PXDBDecimal()]
[PXUIField(DisplayName = "Total", Enabled = false)]
public virtual Decimal? Total { get; set; }
public abstract class total : PX.Data.BQL.BqlDecimal.Field<total> { }
If you do a code search on PXFormula you should find many examples. I usually search the code found in your site/App_data/CpdeRepository directory if you have access to a local site.
If you are looking to perform a multi field calculations, you nest your Add, Sub, Mult, Div, etc. calls.
Here are some examples from my search on "PXFormula" or "Mult<" or "Add<":
Found in ARTranRUTROT.CuryRUTROTTotal, this example will subtrack curyExtPrice from curyDiscAmt and add curyRUTROTTaxAmountDeductible (unless null use zero)
[PXFormula(typeof(Add<Sub<ARTran.curyExtPrice, ARTran.curyDiscAmt>,
IsNull<curyRUTROTTaxAmountDeductible, decimal0>>))]
Found in GLTaxTran.CuryExpenseAmt. This example again uses multiple fields in the calculation all nested.
[PXFormula(typeof(Mult<Mult<GLTaxTran.curyTaxableAmt,
Div<GLTaxTran.taxRate, decimal100>>, Sub<decimal1,
Div<GLTaxTran.nonDeductibleTaxRate, decimal100>>>), null)]

How do you determine the data type of calling object in Groovy?

When I'm calling a function in Groovy, how do I determine the class of the caller?
For example, I want to know what the class of foo is, inside the printFoo() function:
foo.printFoo()
def printFoo() {
print(this.class)
}
And this should print out the class of foo
I don't know of any Groovy-specific way, but you can get the class name with object.getClass().name. Is that what you are looking for?
If you want to check if an object implements a particular interface or extends a particular class (e.g. Date) use:
object instanceof Date
or to check if the class of an object is exactly a particular class (not a subclass of it), use:
object.getClass() == Date
There's also the in operator: object in Date
The language and the runtime don't provide a reliable mechanism to do what you are asking about. You can do some pokey jiggery inspecting stack frames but that is really detailed low level stuff and won't really be reliable for a number of reasons. The short answer is, the language just doesn't support it.

Resources