dirichlet | light weight package for the dirichlet functions | Analytics library
kandi X-RAY | dirichlet Summary
kandi X-RAY | dirichlet Summary
A light weight package for the (d/r)dirichlet functions for the Dirichlet distribution in R
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of dirichlet
dirichlet Key Features
dirichlet Examples and Code Snippets
def _kl_dirichlet_dirichlet(d1, d2, name=None):
"""Batchwise KL divergence KL(d1 || d2) with d1 and d2 Dirichlet.
Args:
d1: instance of a Dirichlet distribution object.
d2: instance of a Dirichlet distribution object.
name: (optional
Community Discussions
Trending Discussions on dirichlet
QUESTION
I know that some scipy.stats
pdf functions are vectorized out of the box, as stated in the manual.
My problem is that I've tried utilizing this vectorization with Dirichlet's pdf, scipy.stats.dirchlet.pdf(x, alpha)
hopping that I could calculate an array of values for multiple x
's for the same alpha
parameter. Something that could get the same results as
ANSWER
Answered 2021-Jun-06 at 07:52You can obtain the exact result you want by simply transposing the first argument:
QUESTION
I am wondering which technique is used to learn the Dirichlet priors in Mallet's LDA implementation.
Chapter 2 of Hanna Wallach's Ph.D. thesis gives a great overview and a valuable evaluation of existing and new techniques to learn the Dirichlet priors from the data.
Tom Minka initially provided his famous fixed-point iteration approach, however without any evaluation or recommendations.
Furthermore, Jonathan Chuang did some comparisons between previously proposed methods, including the Newton−Raphson method.
LiangJie Hong says the following in his blog:
A typical approach is to utilize Monte-Carlo EM approach where E-step is approximated by Gibbs sampling while M-step is to perform a gradient-based optimization approach to optimize Dirichlet parameters. Such approach is implemented in Mallet package.
Mallet mentions the Minka's fixed-point iterations with and without histograms.
However, the method that is actually used simply states:
Learn Dirichlet parameters using frequency histograms
Could someone provide any reference that describes the used technique?
...ANSWER
Answered 2021-May-21 at 13:47It uses the fixed point iteration. The frequency histograms method is just an efficient way to calculate it. They provide an algebraically equivalent way to do the exact same computation. The update function consists of a sum over a large number of Digamma functions. This function by itself is difficult to compute, but the difference between two Digamma functions (where the arguments differ by an integer) is relatively easy to compute, and even better, it "telescopes" so that the answer to Digamma(a + n) - Digamma(a) is one operation away from the answer to Digamma(a + n + 1) - Digamma(a). If you work through the histogram of counts from 1 to the max, adding up the number of times you saw a count of n at each step, the calculation becomes extremely fast. Initially, we were worried that hyperparameter optimization would take so long that no one would do it. With this trick it's so fast it's not really significant compared to the Gibbs sampling.
QUESTION
I am trying to get in touch with Gaussian Process Classification and try to reproduce the example from https://docs.gpytorch.ai/en/stable/examples/01_Exact_GPs/GP_Regression_on_Classification_Labels.html
Following their code, I want to import the Dirichlet Classification Likelihood by
...ANSWER
Answered 2021-Apr-21 at 07:29Solved it.
The paths of Jupyter Notebook did not include the new updated library. After updating paths to the wanted folder by
QUESTION
I want to make a mixture of two TruncatedNormal distributions in pymc3.
I am trying to modify this piece of documentation. See example #2 for Poisson.
...ANSWER
Answered 2021-Apr-15 at 16:01You don't need to give the distribution a name. The string tn1
passed as first the argument to pm.TruncatedNormal.dist
is interpreted as mu
(as you pass a named mu
also, you get the exception). Try
QUESTION
ANSWER
Answered 2021-Apr-08 at 20:43
- why are the values of phi and phi2 slightly different?
phi
and phi2
are different because eq2
doesn't converge as rapidly as eq1
. This is because eq1
is more implicit than eq2
. If you change the tolerance for the residual, e.g., res > 1e-10
, you'll see the two solutions are in much closer agreement.
- how could I extract the outflow term for each cell (when a more complex grid will be used) while keeping 'ImplicitSourceTerm', which is more efficient?
You can still evaluate the flux phi2 * extCoef * phi2.faceGrad
, even when you use the ImplicitSourceTerm
.
In general, it's not easy to extract what each Term
is doing physically (see issue #461). You can use the FIPY_DISPLAY_MATRIX
environment variable to see how each Term
contributes to the solution matrix, but this may or may not give you much physical intuition for what's going on.
QUESTION
I am new to Julia and I am really surprised by the behavior of the following code.
...ANSWER
Answered 2021-Apr-06 at 19:34Moving to Julia 1.5 fixed the issue.
QUESTION
Let me start by saying that I have found similar problems to mine on the NARKIVE FiPy mailing list archive but since the equations won't load, they are not very useful. For example Convection-diffusion problem on a 1D cylindrical grid, or on another mailing list archive Re: FiPy Heat Transfer Solution. In the second linked mail Daniel says:
There are two ways to solve on a cylindrical domain in FiPy. You can either use the standard diffusion equation in Cartesian coordinates (2nd equation below) and with a mesh that is actually cylindrical in shape or you can use the diffusion equation formulated on a cylindrical coordinate system (1st equation below) and use a standard 2D / 1D grid mesh.
And the equations are not there. In this case it is actually fine because I understand the first solution and I want to use that.
I want to solve the following equation on a 1D cylindrical grid (sorry I don't have 10 reputation yet so I cannot post the nice rendered equations):
with boundary conditions:
where rho_core is the left side of the mesh, and rho_edge is the right side of the mesh. rho is the normalized radius, J is the Jacobian:
R is the real radius in meters, so the dimension of the Jacobian is distance. The initial conditions doesn't really matter, but in my code example I will use a numerical Dirac-delta at R=0.8
.
I have a working example without(!) the Jacobian, but it's quite long, and it doesn't use FiPy's Viewers so I'll link a gist: https://gist.github.com/leferi99/142b90bb686cdf5116ef5aee425a4736
The main part in question is the following:
...ANSWER
Answered 2021-Apr-02 at 14:26[cobbling an answer from the discussion in the comments]
The results are similar between a Grid1D
and a CylindricalGrid1D
, particularly in the early steps, but they are not the same. They are quite different as the problem evolves.
FiPy doesn't like things outside the divergence, but you should be able to multiply the equation by J
and put it in the coefficient of the TransientTerm
, e.g.,
or
QUESTION
I am trying to apply the latent dirichlet allocation algorithm to a .csv file retrieved from twitter data.
Currently I run across the error:
...ANSWER
Answered 2021-Feb-24 at 20:45I believe you want to select the top 10 words and you are using a wrong syntax. You are only selecting the word ranked 10 which is not iterable. Change line 261 to this to select the top 10 instead of only selecting the 10th:
QUESTION
I have data that is a 50:50 mix of a normal distribution and a constant value:
...ANSWER
Answered 2021-Mar-07 at 03:45The issue here is that the likelihood of coming from each model involves probability density for the Gaussian and mass for the discrete, which are not commensurate. Specifically, the computation for comparing where a zero observation came from, will involve likelihoods
QUESTION
I simply want to create a random matrix A whose vectors are drawn from the Dirichlet distribution. The function works fine with numpy:
...ANSWER
Answered 2021-Feb-28 at 15:33This is a bug in cupy which you should report on their GitHub.
They do not properly handle the case of an integer argument, despite the documentation. They require that you provide either a tuple or None
. This is why you see the behavior you’re seeing. (If you provided a tuple (a, b)
, then the resulting shape would properly be (a, b, n)
.
The workaround here is to provide the shape you want as a length-1 tuple: (n,)
. Note that the comma is necessary.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install dirichlet
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page