Skip to content

Conversation

saurabhraghuvanshii
Copy link
Contributor


type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes. report:

  • task: lint_filenames status: passed
  • task: lint_editorconfig status: passed
  • task: lint_markdown status: passed
  • task: lint_package_json status: passed
  • task: lint_repl_help status: na
  • task: lint_javascript_src status: passed
  • task: lint_javascript_cli status: na
  • task: lint_javascript_examples status: na
  • task: lint_javascript_tests status: passed
  • task: lint_javascript_benchmarks status: passed
  • task: lint_python status: na
  • task: lint_r status: na
  • task: lint_c_src status: passed
  • task: lint_c_examples status: passed
  • task: lint_c_benchmarks status: passed
  • task: lint_c_tests_fixtures status: na
  • task: lint_shell status: na
  • task: lint_typescript_declarations status: na
  • task: lint_typescript_tests status: na
  • task: lint_license_headers status: passed ---

Resolves #3788

Description

What is the purpose of this pull request?

This pull request:

  • Add C implementation for @stdlib/stats/base/dists/poisson/logpmf

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers


#### stdlib_base_dists_poisson_logpmf( x, lambda )

Evaluates the natural logarithm of the probability mass function (PMF) for a Poisson distribution with mean parameter `lambda` at a value `x`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Evaluates the natural logarithm of the probability mass function (PMF) for a Poisson distribution with mean parameter `lambda` at a value `x`.
Evaluates the natural logarithm of the probability mass function (PMF) for a Poisson distribution with mean parameter `lambda`.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should match the JSDoc API call mentioned above

Copy link
Member

@Neerajpathak07 Neerajpathak07 Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you should change this as well for main.c & include.h



/**
* Evaluates the quantile function for a Poisson distribution with mean parameter `lambda` at a probability `p`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you copied the incorrect call from poisson/quantile.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay let's see

#endif

/**
* Returns the logpmf of a Poisson distribution.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake

@Neerajpathak07
Copy link
Member

Neerajpathak07 commented Jan 31, 2025

@saurabhraghuvanshii
Also could you change your PR title to :-
feat: add C implementation for stats/base/dists/poisson/logpmf

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ceil( randu()*50.0 );
y = mypmf( x );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
y = mypmf( x );
y = mypmf( x[ i % len ] );

Copy link
Member

@Neerajpathak07 Neerajpathak07 Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as you want to implement the discreteUniform logic that you created for var x for your function mypmf() as well right

@saurabhraghuvanshii
Copy link
Contributor Author

@saurabhraghuvanshii Also you you change your PR title to :- feat: add C implementation for stats/base/dists/poisson/logpmf

But I refer issue for title

"@stdlib/math/base/special/factorialln",
"@stdlib/math/base/special/ceil",
"@stdlib/math/base/special/ln",
"@stdlib/math/base/assert/is-nan"
Copy link
Member

@Neerajpathak07 Neerajpathak07 Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"@stdlib/math/base/assert/is-nan"
"@stdlib/math/base/assert/is-nan",
"@stdlib/constants/float64/pinf",
"@stdlib/constants/float64/ninf"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do the same for other builds as well!

@Neerajpathak07
Copy link
Member

Neerajpathak07 commented Jan 31, 2025

@saurabhraghuvanshii Also you you change your PR title to :- feat: add C implementation for stats/base/dists/poisson/logpmf

But I refer issue for title

Ok, but while creating a PR for that issue we refer the package name from the root package in which the package is added.
In this instance it is stats

@saurabhraghuvanshii saurabhraghuvanshii changed the title feat: add c implementation for @stdlib/stats/base/dists/poisson/logpmf feat: add c implementation for stats/base/dists/poisson/logpmf Jan 31, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Jan 31, 2025

Coverage Report

No coverage information available.

@saurabhraghuvanshii
Copy link
Contributor Author

done everything as your suggestion.

var i;

lambda = 10.0;
lambda = 100;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please take a look at the suggested change properly.
you require to set a value for var len and not tamper the original set val of lambda

Copy link
Contributor Author

@saurabhraghuvanshii saurabhraghuvanshii Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aaaah man sorry

* Evaluates the quantile function for a Poisson distribution with mean parameter `lambda`.
*
* @param x input value
* @param lambda mean parameter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be stacked one above the another

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in local it is align but in commit it doesn't show

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's because they are tab indented which is incorrect there should be spaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how I can do this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do one thing remove the entire C doxygen and write it again this time using spaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done .

Comment on lines 193 to 195
delta = abs( y - expected[ i ] );
tol = 80.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
Copy link
Member

@Neerajpathak07 Neerajpathak07 Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As suggested by the maintainers.
Should check whether the non-exact check is necessary. There are no calculations that would suggest it's needed. If also present in test file, would be good to remove from that as well.

Copy link
Contributor Author

@saurabhraghuvanshii saurabhraghuvanshii Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it not in test.js it is in test.logpmf.js should I do changes in that file.

Copy link
Member

@Neerajpathak07 Neerajpathak07 Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea that would be desirable.

@Neerajpathak07
Copy link
Member

@saurabhraghuvanshii Thanks for the PR. Left a few comments other than that everything else is in pretty good shape.

@saurabhraghuvanshii
Copy link
Contributor Author

@Neerajpathak07 lost my all commit try recover but didn't joning to create a new pr

@saurabhraghuvanshii
Copy link
Contributor Author

@Neerajpathak07 you can check in new pr #5194 if any changes need i do . thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: Add C implementation for @stdlib/stats/base/dists/poisson/logpmf

3 participants