Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.3K Views
|
5 Replies
|
1 Total Like
View groups...
Share
Share this post:

Test that two functions are equivalent

POSTED BY: Frank MacCrory
5 Replies

Sorry for not including copiable code in the original message; it didn't seem to me to bear on the question of comparing two functions, and it didn't render quite as I expected. Should work, though.

(* Original, intended definition *)
MDistribution[f_, a_] = ProbabilityDistribution[a*Cos[f*2*\[Pi]*x] + 1, {x, 0, 1}];

(* The above behaves oddly at the endpoints, this was the suggested fix: *)
pdf2 = Piecewise[{{0, 1 < x < \[Infinity]}, {a*Cos[f*2*\[Pi]*x] + 1, 0 <= x <= 1}, {0, -\[Infinity] < x < 0}}]
MDistribution[f_, a_] = ProbabilityDistribution[pdf2, {x, -\[Infinity], \[Infinity]}];

FullSimplify[ForAll[n, PDF[MDistribution[f, 0]][n] == PDF[UniformDistribution[{0, 1}]][n]]]
FullSimplify[ForAll[n, CDF[MDistribution[f, 0]][n] == CDF[UniformDistribution[{0, 1}]][n]]]

Thank you for looking!

POSTED BY: Frank MacCrory
POSTED BY: Daniel Lichtblau

Thank you!

Resolve[...,Reals] is precisely what I needed to ask my question in a way that Mathematica would understand it. The previous results were confusing without the Reals qualifier because I thought it assumed Reals whenever a variable gets used in an inequality.

Maybe an inequality in a Piecewise[] function doesn't count as getting used in an inequality.

POSTED BY: Frank MacCrory

I was wondering pretty much the same thing about inequalities.

POSTED BY: Daniel Lichtblau

Please add actual code for a minimal complete example that is copy-pastable. I don't want to retype just to test things.

POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard